0

好的。我发现很难说清楚。让我试试。

我正在使用广播接收器来为每个呼叫调用。

<receiver
    android:name="com.example.receiveCall"
    android:enabled="true" >
    <intent-filter>
        <action android:name="android.intent.action.PHONE_STATE" />
    </intent-filter>
</receiver>

在 onReceive 方法中,我在顶部开始了一个活动。

    @Override
    public void onReceive(final Context context, Intent intent) {

            Handler mHandler = new Handler();
            AttendActivity.ctx = context;
            Runnable mUpdateTimeTask = new Runnable() {
                public void run() {
                    // do what you need to do here after the delay
//                  context.startService(new Intent(context, AutoAnswerIntentService.class));
                    context.startActivity(new Intent(context,
                            AttendActivity.class)
                            .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));

                }
            };
            mHandler.postDelayed(mUpdateTimeTask, 500);
        }       
    }

当应用程序不可见时,这可以正常工作。但是当应用程序可见时。我的活动在 InCallScreen 顶部打开。但是当我关闭参加活动时。而不是 InCallScreen 我的应用程序是可见的。Incallscreen 就在它上面。

你能帮我解决这个问题吗?期望的输出

MyApp -> InCallScreen -> AttendActivity

当前输出 InCallScreen -> MyApp -> AttendActivity

4

1 回答 1

0

我推荐阅读这篇文章。它有大量关于 Android 中的活动、任务、应用程序和进程的信息。

我的猜测是您的 AttendActivity 具有默认的任务关联性。这意味着如果显示此活动,那么您的整个任务(很可能是您应用程序的所有活动)将被带到前面。

您可以更改此行为。您需要在 Manifest 中对您的活动进行 android:taskAffinity。

例如,您可以将 AttendActivity 的 android:taskAffinity="" 放在清单中。这样,当它被带到前面时,它不会拖动整个应用程序。

于 2012-09-06T02:46:37.690 回答