Bom, nunca fiz nada relacionado, mais eu faria da mesma forma, interceptaria os listeners do Phone!
Considero correta!
[]
rbarbioni
2013/3/28 Francis Mariano <francismariano@gmail.com>
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() {@Overridepublic void onCallStateChanged(int state, String incomingNumber) {if (state == TelephonyManager.CALL_STATE_RINGING) {//Incoming call: Pause musicsetPause();} else if(state == TelephonyManager.CALL_STATE_IDLE) {//Not in call: Play musicsetPlay();} 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.
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