1

目前,当我们通过应用程序拨打语音电话时,整个屏幕都被通话 UI 占据。有没有办法将通话感觉包含在对话框中并为其提供一些边距,以便用户在通话完成后无需记住按回进入应用程序?

基本上我不希望客户需要记住按下“返回”按钮。

我正在使用下面的代码拨打电话。但不是打开最后一个活动,而是打开第一个启动屏幕。我需要它来隐藏。

编辑 :

PhoneCallListener phoneListener = new PhoneCallListener();
TelephonyManager telephonyManager = (TelephonyManager) this
        .getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.listen(phoneListener, PhoneCallListener.LISTEN_CALL_STATE);

Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + cabbiePhoneNumber));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

我现在使用 PhoneStateListener 来监听电话状态。

private class PhoneCallListener extends PhoneStateListener {
    private boolean isPhoneCalling = false;
    String LOG_TAG = "LOGGING 123";
    @Override
    public void onCallStateChanged(int state, String incomingNumber) {
        if (TelephonyManager.CALL_STATE_RINGING == state) {
            // phone ringing
            Log.i(LOG_TAG, "RINGING, number: " + incomingNumber);
        }
        if (TelephonyManager.CALL_STATE_OFFHOOK == state) {
            // active
            Log.i(LOG_TAG, "OFFHOOK");
            isPhoneCalling = true;
        }
        if (TelephonyManager.CALL_STATE_IDLE == state) {
            // run when class initial and phone call ended,
            // need detect flag from CALL_STATE_OFFHOOK
            Log.i(LOG_TAG, "IDLE");
            if (isPhoneCalling) {
                Log.i(LOG_TAG, "restart app");
                // restart app
                Intent i = getBaseContext().getPackageManager().getLaunchIntentForPackage(
                        getBaseContext().getPackageName());
                i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(i);
                isPhoneCalling = false;
            }
        }
    }
4

2 回答 2

1

没有内置呼叫 UI 的语音呼叫无法通过 SDK 应用程序进行。您必须推出自己的固件才能实现这一点。

于 2013-08-17T09:55:35.160 回答
0

我设法解决了这个问题。基本上只需要不做 getBaseContext().find 父级并启动 thingy。

我需要启动我需要的活动。

BookingExperience.this.showDriverDetails();

private class PhoneCallListener extends PhoneStateListener {
    private boolean isPhoneCalling = false;
    String LOG_TAG = "LOGGING 123";

    @Override
    public void onCallStateChanged(int state, String incomingNumber) {
        if (TelephonyManager.CALL_STATE_RINGING == state) {
            // phone ringing
            Log.i(LOG_TAG, "RINGING, number: " + incomingNumber);
        }
        if (TelephonyManager.CALL_STATE_OFFHOOK == state) {
            // active
            Log.i(LOG_TAG, "OFFHOOK");
            isPhoneCalling = true;
        }
        if (TelephonyManager.CALL_STATE_IDLE == state) {
            // run when class initial and phone call ended,
            // need detect flag from CALL_STATE_OFFHOOK
            Log.i(LOG_TAG, "IDLE");
            if (isPhoneCalling) {
                Log.i(LOG_TAG, "restart app");
                // restart app
                BookingExperience.this.showDriverDetails();
                // getApplicationContext().getPackageManager().getLaunchIntentForPackage(
                // getBaseContext().getPackageName());
                // i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                // startActivity(i);
                isPhoneCalling = false;
            }
        }
    }
}
于 2013-08-17T15:32:40.430 回答