Example of Android jump to app notification settings interface

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.