<bdo id='7HS9V'></bdo><ul id='7HS9V'></ul>

    1. <i id='7HS9V'><tr id='7HS9V'><dt id='7HS9V'><q id='7HS9V'><span id='7HS9V'><b id='7HS9V'><form id='7HS9V'><ins id='7HS9V'></ins><ul id='7HS9V'></ul><sub id='7HS9V'></sub></form><legend id='7HS9V'></legend><bdo id='7HS9V'><pre id='7HS9V'><center id='7HS9V'></center></pre></bdo></b><th id='7HS9V'></th></span></q></dt></tr></i><div id='7HS9V'><tfoot id='7HS9V'></tfoot><dl id='7HS9V'><fieldset id='7HS9V'></fieldset></dl></div>
    2. <tfoot id='7HS9V'></tfoot>
    3. <small id='7HS9V'></small><noframes id='7HS9V'>

      1. <legend id='7HS9V'><style id='7HS9V'><dir id='7HS9V'><q id='7HS9V'></q></dir></style></legend>

        如何在Android App中获取通话结束事件

        时间:2023-06-27

          <small id='gsT4Y'></small><noframes id='gsT4Y'>

            <tbody id='gsT4Y'></tbody>

          • <tfoot id='gsT4Y'></tfoot>
              • <bdo id='gsT4Y'></bdo><ul id='gsT4Y'></ul>
                <i id='gsT4Y'><tr id='gsT4Y'><dt id='gsT4Y'><q id='gsT4Y'><span id='gsT4Y'><b id='gsT4Y'><form id='gsT4Y'><ins id='gsT4Y'></ins><ul id='gsT4Y'></ul><sub id='gsT4Y'></sub></form><legend id='gsT4Y'></legend><bdo id='gsT4Y'><pre id='gsT4Y'><center id='gsT4Y'></center></pre></bdo></b><th id='gsT4Y'></th></span></q></dt></tr></i><div id='gsT4Y'><tfoot id='gsT4Y'></tfoot><dl id='gsT4Y'><fieldset id='gsT4Y'></fieldset></dl></div>
                <legend id='gsT4Y'><style id='gsT4Y'><dir id='gsT4Y'><q id='gsT4Y'></q></dir></style></legend>
                • 本文介绍了如何在Android App中获取通话结束事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我已经为 Android 手机制作了小应用程序.

                  I have made small app for Android mobile.

                  在一种情况下,我没有得到任何解决方案.实际上,我的应用程序具有呼叫客户的小功能.

                  In one situation I am not getting any solution. Actually my app has small functionality for calling to customer.

                  所以在通话结束后,我需要拨打最后一个号码或运行哪个应用程序的事件.

                  So after call ended I need that event of which last number will dialed or which app is runs.

                  推荐答案

                  AndroidManifest:

                  <receiver android:name=".PhoneStateBroadcastReceiver">  
                         <intent-filter>  
                                 <action android:name="android.intent.action.PHONE_STATE">       
                         </action></intent-filter>  
                  </receiver> 
                  

                  添加以下权限:

                  <uses-permission android:name="android.permission.READ_PHONE_STATE">  
                  </uses-permission>  
                  

                  PhoneStateBroadcastReceiver.java(稍微重构了代码)

                  package com.mobisys.android.salesbooster;
                  
                  import com.mobisys.android.salesbooster.database.HelperDatabase;
                  
                  import android.content.BroadcastReceiver;
                  import android.content.Context;
                  import android.content.Intent;
                  import android.content.SharedPreferences;
                  import android.database.Cursor;
                  import android.net.Uri;
                  import android.os.Bundle;
                  import android.preference.PreferenceManager;
                  import android.provider.ContactsContract.PhoneLookup;
                  import android.telephony.PhoneStateListener;
                  import android.telephony.TelephonyManager;
                  import android.util.Log;
                  
                  public class PhoneStateBroadcastReceiver extends BroadcastReceiver {
                  
                      private static final String TAG = "PhoneStateBroadcastReceiver";
                      Context mContext;
                      String incoming_number;
                      private int prev_state;
                  
                      @Override
                      public void onReceive(Context context, Intent intent) {
                          TelephonyManager telephony = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); //TelephonyManager object
                          CustomPhoneStateListener customPhoneListener = new CustomPhoneStateListener();
                          telephony.listen(customPhoneListener, PhoneStateListener.LISTEN_CALL_STATE); //Register our listener with TelephonyManager
                  
                          Bundle bundle = intent.getExtras();
                          String phoneNr = bundle.getString("incoming_number");
                          Log.v(TAG, "phoneNr: "+phoneNr);
                          mContext = context;
                      }
                  
                      /* Custom PhoneStateListener */
                      public class CustomPhoneStateListener extends PhoneStateListener {
                  
                          private static final String TAG = "CustomPhoneStateListener";
                  
                          @Override
                          public void onCallStateChanged(int state, String incomingNumber){
                  
                             if( incomingNumber != null && incomingNumber.length() > 0 ) 
                              incoming_number = incomingNumber; 
                  
                              switch(state){
                                  case TelephonyManager.CALL_STATE_RINGING:
                                          Log.d(TAG, "CALL_STATE_RINGING");
                                          prev_state=state;
                                          break;
                  
                                  case TelephonyManager.CALL_STATE_OFFHOOK:
                                                  Log.d(TAG, "CALL_STATE_OFFHOOK");
                                                  prev_state=state;
                                                  break;
                  
                                  case TelephonyManager.CALL_STATE_IDLE:
                  
                                      Log.d(TAG, "CALL_STATE_IDLE==>"+incoming_number);
                  
                                      if((prev_state == TelephonyManager.CALL_STATE_OFFHOOK)){
                                          prev_state=state;
                                          //Answered Call which is ended
                                      }
                                      if((prev_state == TelephonyManager.CALL_STATE_RINGING)){
                                          prev_state=state;
                                          //Rejected or Missed call
                                      }
                                      break;
                              }
                          }
                      }
                  }
                  

                  在此处阅读更多信息,来源:http://mobisys.在/blog/2011/09/is-your-call-ended-on-android-phone/

                  Read more here, Source : http://mobisys.in/blog/2011/09/is-your-call-ended-on-android-phone/

                  这篇关于如何在Android App中获取通话结束事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 DDMS (Android) 中更改文件权限 下一篇:如何停止在 Eclipse 下运行的程序?

                  相关文章

                      <bdo id='bky8u'></bdo><ul id='bky8u'></ul>
                    1. <legend id='bky8u'><style id='bky8u'><dir id='bky8u'><q id='bky8u'></q></dir></style></legend>
                    2. <tfoot id='bky8u'></tfoot>

                      <i id='bky8u'><tr id='bky8u'><dt id='bky8u'><q id='bky8u'><span id='bky8u'><b id='bky8u'><form id='bky8u'><ins id='bky8u'></ins><ul id='bky8u'></ul><sub id='bky8u'></sub></form><legend id='bky8u'></legend><bdo id='bky8u'><pre id='bky8u'><center id='bky8u'></center></pre></bdo></b><th id='bky8u'></th></span></q></dt></tr></i><div id='bky8u'><tfoot id='bky8u'></tfoot><dl id='bky8u'><fieldset id='bky8u'></fieldset></dl></div>

                      <small id='bky8u'></small><noframes id='bky8u'>