Recently the project is busy, finally has the free time to write the thing.
Believe that the Android has been known, the current mobile phone system is a variety of, when we go to request the user's permission, will always pop up whether the allowed dialog box.
And once the user is not careful to refuse, the next time will not ask, and many small white users do not know how to set. This leads to a very bad user experience.
After research, I found that the system, such as Xiaomi, Meizu, and these full-street systems, can be opened by the implicit intention to open the Permissions Settings page.
This refers to the Rights Management page of the app itself.
Some people have written similar articles before, but they are scattered, and I have summed up these methods here.
Not much to say, directly on the code.
First is the most egg pain millet, Baidu a lot of predecessors left the method, found can not open, no way, only through the ADB Dumpsys activity activities command to see
After some research has finally opened.
/** * Jump to MIUI's Rights Management page*/ Private voidgotomiuipermission () {Intent I=NewIntent ("Miui.intent.action.APP_PERM_EDITOR"); ComponentName componentname=NewComponentName ("Com.miui.securitycenter","com.miui.permcenter.permissions.AppPermissionsEditorActivity"); I.setcomponent (componentname); I.putextra ("Extra_pkgname", Getpackagename ()); Try{startactivity (i); } Catch(Exception e) {e.printstacktrace (); Gotomeizupermission (); } }
Next up Meizu's code
/** * Jump to Meizu's rights management system*/ Private voidgotomeizupermission () {Intent Intent=NewIntent ("Com.meizu.safe.security.SHOW_APPSEC"); Intent.addcategory (Intent.category_default); Intent.putextra ("PackageName", buildconfig.application_id); Try{startactivity (intent); } Catch(Exception e) {e.printstacktrace (); Gotohuaweipermission (); } }
Huawei's system is not the same, some systems are Huawei's own rights management, and 6.0 is the use of the original Rights Management page, currently has only one 6.0 of Huawei mobile phones,
Temporarily did not study to open the method, if have known the great God trouble to inform
But it doesn't matter, we can retreat. Second, open the Rights Management page for the app you're using
/** * Huawei's Rights Management page*/ Private voidgotohuaweipermission () {Try{Intent Intent=NewIntent (); Intent.setflags (Intent.flag_activity_new_task); ComponentName Comp=NewComponentName ("Com.huawei.systemmanager","com.huawei.permissionmanager.ui.MainActivity");//Huawei Rights Managementintent.setcomponent (comp); StartActivity (Intent); } Catch(Exception e) {e.printstacktrace (); StartActivity (Getappdetailsettingintent ()); } }
At present, the three systems have been studied, for the native system, and other systems, if the method can not be found, it is also possible to first guide the user to the System settings page
/** * Get App Details page Intent * * @return*/ PrivateIntent getappdetailsettingintent () {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", 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", Getpackagename ()); } returnlocalintent; }
Get to intent after the direct startactivity just fine ...
Attainments is not enough, only know so much, welcome you Daniel to add!
Android mobile phone system open the Rights Management page