Android Pie 9.0将用户带到通知中心

时间:2019-02-16 00:30:59

标签: android android-studio push-notification android-9.0-pie

我带用户到通知中心来控制他们的推送通知首选项,并从我的应用程序中读取它,并设置为切换开关。对于Lollipop和Oreo,我有不同的操作,但是当前应用程序对于Android Pie 9.0崩溃。我该如何解决该问题?

class SecurityConfig extends WebSecurityConfigurerAdapter {

  @Override
  public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers(
      "/css/\**",
      "/js/\**",
      "/img/\**",
      ...
    );
  }

  ...
}

错误是

public void onPushSwitchChanged(View v){
    if(v.isPressed()){
        Intent intent = new Intent();
        if(android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1){
            intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
            intent.putExtra("android.provider.extra.APP_PACKAGE", mContext.getPackageName());
        }else if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
            intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
            intent.putExtra("app_package", mContext.getPackageName());
            intent.putExtra("app_uid", mContext.getApplicationInfo().uid);
        }else {
            intent.setAction(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            intent.addCategory(Intent.CATEGORY_DEFAULT);
            intent.setData(Uri.parse("package:" + mContext.getPackageName()));
        }
        mContext.startActivity(intent);
    }
}

1 个答案:

答案 0 :(得分:1)

更新

我通过添加解决了该问题,

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

在我的第一个if块中。