Call_withSpeaker设置警报不在三星4.2.2上工作

时间:2014-05-08 15:50:41

标签: android android-manifest alarmmanager

我的应用程序Call_withSpeaker设置闹钟在android 4.2.1 micromax,4.1.2 samsung和2.3 motorala中工作正常。 只有三星4.2.2的问题.. 每件事情都很好,但扬声器不能在4.2.2三星电话中启动。我正在使用PhoneStateListener,如果我使用

,请致电
AudioManager audioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
                  audioManager.setMode(AudioManager.MODE_IN_CALL);
                  audioManager.setSpeakerphoneOn(true);  

我在这里遇到的问题是Turn Speaker Phone打开和关闭仅适用于Samsung 4.2.2和samsung duas 4.1.2 怎么办..有什么想法?它与移动版本或某些设置有关吗??? 谢谢..

1 个答案:

答案 0 :(得分:0)

这只是因为在某些移动设备(SdkVersion 11及更高版本)中,它不通过TelephonyManager.CALL_STATE_OFFHOOKTelephonyManager.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;


           }

}