我正在尝试更多标志以防止同时打开多次活动

时间:2017-03-31 19:13:15

标签: android android-intent android-activity android-pendingintent mobile-development

我试过像

这样的旗帜
 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |Intent.FLAG_ACTIVITY_CLEAR_TASK);

i登录我的应用程序并打开主页>当我收到通知并在其上预先看到主页上的详细信息时,它打开的很好但是之前的

1 个答案:

答案 0 :(得分:0)

您可以在启动模式

的帮助下实现此目的

转到声明您的活动声明的位置。 并将以下属性添加到您的活动声明中。

<强>机器人:launchMode = “singleTask”

并在你的活动类ovveride方法

public void onNewIntent(Intent intent) {
   setIntent(intent);
   //do other stuff with new intent
}

我还建议您阅读有关活动启动模式https://developer.android.com/guide/topics/manifest/activity-element.html

的更多信息
相关问题