我开发了带有服务的基本无线电流应用程序。来电后,无线电流继续,但声音播放顶部扬声器。我想从所有扬声器播放它。如何做到这一点?
问问题
73 次
1 回答
0
private final PhoneStateListener phoneListener = new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
try {
switch (state) {
case TelephonyManager.CALL_STATE_RINGING: {
//PAUSE
if(BackgroundAudioService.mediaPlayer!=null){
BackgroundAudioService.mediaPlayer.pause();}
Log.i("pause","pause");
break;
}
case TelephonyManager.CALL_STATE_OFFHOOK: {
break;
}
case TelephonyManager.CALL_STATE_IDLE: {
//PLAY
if(BackgroundAudioService.mediaPlayer!=null){
BackgroundAudioService.mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
BackgroundAudioService.mediaPlayer.start();
Log.i("play","play");
}
break;
}
default: { }
}
} catch (Exception ex) {
}
}
};
于 2014-11-06T12:32:04.163 回答