Bom dia pessoal, eu to fazendo um media player e percebi q qdo recebo chamada a musica fica tocando em background, pensei que o Android manipulasse isso automaticamente. Resolvi esse problema com a solução abaixo, é a melhor maneira??
Se for, fica minha contribuição para esse problema.
-- phoneStateListener = new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
if (state == TelephonyManager.CALL_STATE_RINGING) {
//Incoming call: Pause music
setPause();
} else if(state == TelephonyManager.CALL_STATE_IDLE) {
//Not in call: Play music
setPlay();
} else if(state == TelephonyManager.CALL_STATE_OFFHOOK) {
//A call is dialing, active or on hold
}
super.onCallStateChanged(state, incomingNumber);
}
};
TelephonyManager mgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
if(mgr != null) {
mgr.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
}
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.






0 comentários:
Postar um comentário