【问题标题】:i am Trying more Flags to prevent the Activity to be opened more than one time at the Same time我正在尝试更多标志以防止 Activity 同时打开多次
【发布时间】:2017-03-31 19:13:15
【问题描述】:

我试过像

这样的标志
 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |Intent.FLAG_ACTIVITY_CLEAR_TASK);

我登录到我的应用程序并打开主页 > 当我收到通知并按下它以查看主页上的详细信息时,它打开得很好但是以前的

【问题讨论】:

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


    【解决方案1】:

    你可以在启动模式的帮助下实现这一点

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

    android:launchMode="singleTask"

    并且在您的活动类中使用以下方法

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

    我也建议你阅读更多关于活动启动模式https://developer.android.com/guide/topics/manifest/activity-element.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多