我想打个电话,在通话结束后我想回来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
?