4.4 The following is not mentioned from the app to jump to the app Notification Settings page action, you can consider jumping to the app details page, below is directly jump to the app notification settings code:
if(Android.os.Build.VERSION.SDK_INT >=Build.version_codes. LOLLIPOP) {Intent Intent=NewIntent (); Intent.setaction ("Android.settings.APP_NOTIFICATION_SETTINGS"); Intent.putextra ("App_package", Getactivity (). Getpackagename ()); Intent.putextra ("App_uid", Getactivity (). Getapplicationinfo (). UID); StartActivity (Intent); } Else if(Android.os.Build.VERSION.SDK_INT = =Build.version_codes. KITKAT) {Intent Intent=NewIntent (); Intent.setaction (settings.action_application_details_settings); Intent.addcategory (Intent.category_default); Intent.setdata (Uri.parse ("Package:" +getactivity (). Getpackagename ()); StartActivity (Intent); }
The code to jump to the app details page is as follows:
Intent localintent =NewIntent (); Localintent.addflags (Intent.flag_activity_new_task); if(Build.VERSION.SDK_INT >= 9) {localintent.setaction ("Android.settings.APPLICATION_DETAILS_SETTINGS"); Localintent.setdata (Uri.fromparts ("Package", Getactivity (). Getpackagename (),NULL)); } Else if(Build.VERSION.SDK_INT <= 8) {localintent.setaction (Intent.action_view); Localintent.setclassname ("Com.android.settings", "Com.android.settings.InstalledAppDetails"); Localintent.putextra ("Com.android.settings.ApplicationPkgName", Getactivity (). Getpackagename ()); } startactivity (localintent);
It is also valid for more than 4.4 systems to detect if the app is turned on:
Notificationmanagercompat manager = notificationmanagercompat.from (app.getinstance (). GetContext ()); boolean isopened = manager.arenotificationsenabled ();
4.4 The following call to the method does not make an error, but all returns True, by default the state is turned on
---------
Android to determine if app notification permissions are turned on
Scenario: Determine if the user has blocked the app's push permissions
Notificationmanagercompat.from (context). arenotificationsenabled ()
Example of Android jump to app notification settings interface