<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中获取通话结束事件

        How to get call end event in Android App(如何在Android App中获取通话结束事件)

          <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中获取通话结束事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Lucene Porter Stemmer not public(Lucene Porter Stemmer 未公开)
                  How to index pdf, ppt, xl files in lucene (java based or python or php any of these is fine)?(如何在 lucene 中索引 pdf、ppt、xl 文件(基于 java 或 python 或 php 中的任何一个都可以)?)
                  KeywordAnalyzer and LowerCaseFilter/LowerCaseTokenizer(KeywordAnalyzer 和 LowerCaseFilter/LowerCaseTokenizer)
                  How to search between dates (Hibernate Search)?(如何在日期之间搜索(休眠搜索)?)
                  How to get positions from a document term vector in Lucene?(如何从 Lucene 中的文档术语向量中获取位置?)
                  Java Lucene 4.5 how to search by case insensitive(Java Lucene 4.5如何按不区分大小写进行搜索)

                      <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>
                        • <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'>

                              <tbody id='bky8u'></tbody>