【问题标题】:Application setting page opening twice Android应用程序设置页面打开两次Android
【发布时间】:2021-02-02 18:41:40
【问题描述】:
try {
        intent = new Intent();
        intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            intent.putExtra("android.provider.extra.APP_PACKAGE", getPackageName());
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            intent.putExtra("app_package", getPackageName());
            intent.putExtra("app_uid", getApplicationInfo().uid);
        }
        startActivity(intent);
        } catch (ActivityNotFoundException e) {
           Toast.makeText(AppSettings.this, "Something went wrong.", Toast.LENGTH_LONG).show();
   }

我已经尝试使用上面的代码打开我的应用程序的通知设置,但是当我从同一屏幕(通知设置)单击返回按钮时,我再次进入同一屏幕。有什么相同的建议吗????

【问题讨论】:

    标签: java android notifications


    【解决方案1】:

    我认为android:launchMode 是您正在寻找的。默认情况下它是standard,所以它每次都会创建一个新的活动实例。您应该尝试使用singleTop。更多详情请点击此处https://developer.android.com/guide/topics/manifest/activity-element

    【讨论】:

      猜你喜欢
      • 2011-06-16
      • 1970-01-01
      • 2020-05-16
      • 1970-01-01
      • 1970-01-01
      • 2014-09-21
      • 1970-01-01
      • 1970-01-01
      • 2022-11-09
      相关资源
      最近更新 更多