【问题标题】:Notification click already open application not reopen in android通知单击已打开的应用程序未在 android 中重新打开
【发布时间】:2017-11-17 10:51:34
【问题描述】:

应用程序中使用多个活动点击歌曲通知已打开应用程序未重新打开应用程序如何解决此错误

  Intent notificationIntent = new Intent(this, MainActivity.class);
    notificationIntent.setAction(Control.ACTION.MAIN_ACTION);

    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
            notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

   <activity
        android:name=".Activity.MainActivity"
        android:launchMode="singleTop"
        android:configChanges="orientation|keyboardHidden|screenLayout|screenSize" />

我已经在 android 清单文件中声明了 android:launchMode="singleTop" 所有活动

【问题讨论】:

    标签: android xml push-notification


    【解决方案1】:

    android:launchMode="singleTop"

    这意味着如果活动已经在顶部,它不会创建另一个实例。相反,activityonNewIntent() 将被调用更新意图作为参数。

    @Override
    public void onNewIntent(Intent intent) {
        // Deal with new Intent over here...
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-01
      • 2023-03-11
      • 1970-01-01
      • 2018-10-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多