【问题标题】:Get confirmation call answered on android在 android 上接听确认电话
【发布时间】:2013-06-04 17:30:22
【问题描述】:

我在做android电话号码的处理,你可以知道是否有来电​​,即确认来电是否被接听。使用以下代码进行调用:

Intent callIntent = new Intent (Intent.ACTION_CALL, Uri.parse (number));
startActivity (callIntent);

当您结束对我的应用程序的呼叫时,我想知道呼叫是否已被应答以及是否可能是呼叫的持续时间。

【问题讨论】:

  • nan12 不要一遍又一遍地发布类似的问题

标签: android call duration


【解决方案1】:

是的,您可以,为此您需要创建有意图的 BroadCastReceiver 例如

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

然后在接收器上

    @Override
    public void onReceive(final Context context, Intent intent) {
        String action = intent.getAction();
        if (action.equalsIgnoreCase(PHONE_ACTION)) {
            this.receivePhoneCall(context, intent);
            }
     }

     private void receivePhoneCall(Context context, Intent intent) {
        String curState = intent.getExtras().getString("state");

        if (curState.equalsIgnoreCase("RINGING")) {
        } else

        if (curState.equalsIgnoreCase("IDLE") && state.length() > 0) {
            if (!state.equalsIgnoreCase("OFFHOOK")) {

            }
        }

    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-13
    相关资源
    最近更新 更多