我正在尝试更多标志以防止 Activity 同时打开多次
i am Trying more Flags to prevent the Activity to be opened more than one time at the Same time
我试过
这样的标志
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |Intent.FLAG_ACTIVITY_CLEAR_TASK);
我登录到我的应用程序并打开主页 > 当我收到通知并按下它以在主页上查看详细信息时它打开得很好但是之前的
您可以借助启动模式实现此目的
转到声明您的 activity 的清单。
并将以下属性添加到您的 activity 声明中。
android:launchMode="singleTask"
并在您的 activity class ovveride 以下方法中
public void onNewIntent(Intent intent) {
setIntent(intent);
//do other stuff with new intent
}
我还建议您阅读更多有关 activity 启动模式的信息 https://developer.android.com/guide/topics/manifest/activity-element.html
我试过
这样的标志 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |Intent.FLAG_ACTIVITY_CLEAR_TASK);
我登录到我的应用程序并打开主页 > 当我收到通知并按下它以在主页上查看详细信息时它打开得很好但是之前的
您可以借助启动模式实现此目的
转到声明您的 activity 的清单。 并将以下属性添加到您的 activity 声明中。
android:launchMode="singleTask"
并在您的 activity class ovveride 以下方法中
public void onNewIntent(Intent intent) {
setIntent(intent);
//do other stuff with new intent
}
我还建议您阅读更多有关 activity 启动模式的信息 https://developer.android.com/guide/topics/manifest/activity-element.html