CALL_STATE_OFFHOOK在拨号时立即被调用。

问题描述 投票:0回答:1

我是想得到呼叫被接起时的事件。我搜索了一下,发现应该使用CALL_STATE_OFFHOOK。但是这并不奏效。这个状态在号码被拨通时就会被调用。这是我的代码。

@Override
     public void onCallStateChanged(int state, String incomingNumber) {
         if (TelephonyManager.CALL_STATE_RINGING == state) {
             // phone ringing
             // But this gets called as soon as number is dialled.
             endCall();

         }
         if (TelephonyManager.CALL_STATE_OFFHOOK == state) {
             // active
             phoneCalling = true;          

             new CountDownTimer(MyApplication.GetData().getDuration()*1000, 1000) {
                 public void onTick(long millisUntilFinished) {           
                 }
                 public void onFinish() {
                    endCall();
                 }
              }.start();
         }
         // When the call ends launch the main activity again
         if (TelephonyManager.CALL_STATE_IDLE == state) {
             MyApplication.GetData().setIsReturnedFromCall(false);

             if (phoneCalling) {
                 phoneCalling = false;
             }
         }
android telephonymanager
1个回答
0
投票

我发现这是由于我的 call recorder 应用 uninstallingreinstalling 毫无区别。我不得不进入设置,然后是应用程序,点击应用程序,和存储,其次是 clear data. 这就解决了这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.