我使用服务开发基本的无线电流应用程序。来电后,广播流继续,但声音播放顶部扬声器。我想从所有扬声器播放。如何做到这一点?
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) {
}
}
};