我的应用程序Call_withSpeaker在设置警报时在android 4.2.1 micromax,4.1.2三星和2.3 motorala中正常工作。三星4.2.2 ..唯一的问题一切都很好,但仅在4.2.2 samsung中不能启用扬声器。我正在使用PhoneStateListener
,如果我使用一次就开始通话
AudioManager audioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
audioManager.setMode(AudioManager.MODE_IN_CALL);
audioManager.setSpeakerphoneOn(true);
我在这里面临的问题是“打开和关闭扬声器电话”仅对Samsung 4.2.2和Samsung Duas 4.1.2不能正常工作。与版本或手机中的某些设置有关吗?谢谢 ..
这仅仅是因为在一些移动(SdkVersion 11及以上),其不经历TelephonyManager.CALL_STATE_OFFHOOK
和TelephonyManager.CALL_STATE_RINGING
直接调用TelephonyManager.CALL_STATE_IDLE
它无法运行你的逻辑有些情况下这样。如果您检查每个呼叫状态,就会更好地了解问题。
您必须多锻炼大脑.. :)
检查..它将帮助您
if (TelephonyManager.CALL_STATE_RINGING == state) {
Log.i(LOG_TAG, "RINGING start ");
isPhoneCalling = true;
AudioManager audioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
audioManager.setMode(AudioManager.MODE_IN_CALL);
audioManager.setSpeakerphoneOn(true);
}
if (TelephonyManager.CALL_STATE_OFFHOOK == state) {
// active
Log.i(LOG_TAG, "OFFHOOK..callringing");
isPhoneCalling = true;
AudioManager audioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
audioManager.setMode(AudioManager.MODE_IN_CALL);
audioManager.setSpeakerphoneOn(true);
}
if (TelephonyManager.CALL_STATE_IDLE == state) {
// run when class initial and phone call ended, need detect flag
// from CALL_STATE_OFFHOOK
Log.i(LOG_TAG, "_callend on start ");
Log.i("start ", "start "+callFromApp + isPhoneCalling );
if (isPhoneCalling) {
Log.i(LOG_TAG, "IDLE_callendafter ring ");
AudioManager audioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
audioManager.setMode(AudioManager.MODE_NORMAL);
//Deactivate loudspeaker
audioManager.setSpeakerphoneOn(false);
// Remove listener
PhoneCallListener phoneListener = new PhoneCallListener();
TelephonyManager telephonyManager = (TelephonyManager)mContext.getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.listen(phoneListener,PhoneStateListener.LISTEN_NONE);
isPhoneCalling = false;
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句