-
Notifications
You must be signed in to change notification settings - Fork 766
Open
Description
It was a major issue and I fixed as follows
File: PlaybackService.java
TelephonyManager telManager;
boolean wasPlayingBeforePhoneCall=false;
public class LocalBinder extends Binder {
public PlaybackService getService() {
return PlaybackService.this;
}
}
@Override
public void onCreate() {
super.onCreate();
mPlayer = com.aapbd.mediaplayeraudio.player.Player.getInstance();
mPlayer.registerCallback(this);
telManager = (TelephonyManager)this.getSystemService(TELEPHONY_SERVICE);
if (telManager != null) {
telManager.listen(phoneListener,
PhoneStateListener.LISTEN_CALL_STATE);
}
}
PhoneStateListener phoneListener = new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
if (state == TelephonyManager.CALL_STATE_RINGING) {
if(mPlayer==null)
return;
wasPlayingBeforePhoneCall = isPlaying();
pause();
} else if (state == TelephonyManager.CALL_STATE_IDLE) {
if(mPlayer==null)
return;
if (wasPlayingBeforePhoneCall) {
play();
}
} else if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
// A call is dialing,
// active or on hold
if(mPlayer==null)
return;
wasPlayingBeforePhoneCall = isPlaying();
pause();
}
super.onCallStateChanged(state, incomingNumber);
}
};
Metadata
Metadata
Assignees
Labels
No labels