打完电话后回到活动

时间:2013-07-15 12:46:11

标签: android android-activity

我想打个电话,在通话结束后我想回来Activity开始通话。

开始通话的代码:

// Start a call
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + phoneNumber));
startActivity(callIntent);

处理回归活动的代码:

// Monitor phone call activities
private class PhoneCallListener extends PhoneStateListener {

    private boolean isPhoneCalling = false;

    String TAG = "PhoneCallListener";

    @Override
    public void onCallStateChanged(int state, String incomingNumber) {

        // If call ringing
        if (state == TelephonyManager.CALL_STATE_RINGING) {

            Log.d(TAG, "Call ringing, number : " + incomingNumber);
        }
        // Else if call active
        else if (state == TelephonyManager.CALL_STATE_OFFHOOK) {

            Log.d(TAG, "Call active");

            isPhoneCalling = true;
        }
        // Else if call idle
        else if (state == TelephonyManager.CALL_STATE_IDLE) {

            Log.d(TAG, "Call idle");

            if (isPhoneCalling) {

                isPhoneCalling = false;

                // Finish native call application to come back to this
                // activity
                Intent i = new Intent(getIntent());
                i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
                startActivity(i);
            }

        }
    }
} 

使用finish()不起作用。它保持通话应用程序。

如何回到拨打电话的Activity

0 个答案:

没有答案