use of com.github.obsessive.library.eventbus.EventCenter in project SimplifyReader by chentao0707.
the class PhoneCallReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
if (null == intent) {
return;
}
String action = intent.getAction();
if (action.equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
EventBus.getDefault().post(new EventCenter(Constants.EVENT_STOP_PLAY_MUSIC));
} else {
final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.listen(new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
super.onCallStateChanged(state, incomingNumber);
switch(state) {
case TelephonyManager.CALL_STATE_OFFHOOK:
case TelephonyManager.CALL_STATE_RINGING:
EventBus.getDefault().post(new EventCenter(Constants.EVENT_STOP_PLAY_MUSIC));
break;
case TelephonyManager.CALL_STATE_IDLE:
EventBus.getDefault().post(new EventCenter(Constants.EVENT_START_PLAY_MUSIC));
break;
}
}
}, PhoneStateListener.LISTEN_CALL_STATE);
}
}
use of com.github.obsessive.library.eventbus.EventCenter in project SimplifyReader by chentao0707.
the class PlayerActivity method onResume.
@Override
protected void onResume() {
super.onResume();
EventBus.getDefault().post(new EventCenter(Constants.EVENT_STOP_PLAY_MUSIC));
}
use of com.github.obsessive.library.eventbus.EventCenter in project SimplifyReader by chentao0707.
the class PlayerActivity method onPause.
@Override
protected void onPause() {
super.onPause();
EventBus.getDefault().post(new EventCenter(Constants.EVENT_START_PLAY_MUSIC));
}
Aggregations