MIUI application permission settings, miui application Permissions

Source: Internet
Author: User

MIUI application permission settings, miui application Permissions

Whether you think I write well or badly, you can comment below to tell me that your support is the motivation for me to continue writing. Thank you!

As miui becomes increasingly closed, Xiaomi is increasingly demanding on non-free channel application restrictions. More than half of our products are from Xiaomi, in addition, for games like ours that rely on text message payment to maintain revenue, the ban on text message permissions by default is really killing us. By default, all important permissions of a game added to the miui blacklist are forbidden. For example, if the default message sending permission is disabled, the source of income is broken. Therefore, it took a few hours to search for relevant information online. We cannot help users to open the application permissions. At least we can guide users to open the application permissions, and we will guide users to do as simple as possible.


Document 1:Jump to miui application permission settings page (compatible with V5/V6 old version only jump to the upper interface can be) http://www.tuicool.com/articles/jUby6rA

Document 2:Determine whether the current device is Xiaomi http://dev.xiaomi.com/doc/p=254/index.html

Document 3: complete demoHttp://download.csdn.net/detail/tgbus18990140382/8932881


I don't talk much about other things. I just need to go to the code.

First, jump to the permission settings page of the corresponding application through context:

/*** Jump to the application permission settings page http://www.tuicool.com/articles/jUby6rA * @ param context incoming app or activity context, get the application packegename through context, then, use packegename to redirect to determine whether the application * @ return is miui */public static boolean gotoPermissionSettings (Context context) {boolean mark = isMIUI (); if (mark) {// it is compatible with the miui v5/v6 application permission settings page. Otherwise, you will be redirected to the application settings page (the permission settings are on the previous page) try {Intent localIntent = new Intent ("miui. intent. action. APP_PERM_EDITOR "); localIntent. setClassName ("com. miui. securitycenter "," com. miui. permcenter. permissions. apppermissionseditequaltient "); localIntent. putExtra ("extra_pkgname", context. getPackageName (); context. startActivity (localIntent);} catch (ActivityNotFoundException e) {Intent intent = new Intent (Settings. ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri. fromParts ("package", context. getPackageName (), null); intent. setData (uri); context. startActivity (intent) ;}} return mark ;}


The other is to determine whether it is a Xiaomi device, which provides us with a simple and convenient method:
/*** Check whether the phone is miui * @ ref http://dev.xiaomi.com/doc/p=254/index.html * @ return */public static boolean isMIUI () {String device = Build. MANUFACTURER; System. out. println ("Build. MANUFACTURER = "+ device); if (device. equals ("Xiaomi") {System. out. println ("this is a xiaomi device"); return true ;}else {return false ;}}

We can also use the method similar to activtiy to determine whether it is miui. However, this method also has compatibility issues and is not recommended. We also attached the code for your reference:

/*** Determine whether it is miui V5/V6. The old miui cannot be compatible with * @ param context * @ return */public static boolean isMIUIv5v6 (Context context) {boolean result = false; intent localIntent = new Intent ("miui. intent. action. APP_PERM_EDITOR "); localIntent. setClassName ("com. miui. securitycenter "," com. miui. permcenter. permissions. apppermissionseditinclutivity "); if (isIntentAvailable (context, localIntent) {result = true;} return result ;} /*** check whether the activity * @ param context * @ param intent * @ return */private static boolean isIntentAvailable (Context context, Intent intent) {PackageManager packageManager = context. getPackageManager (); List <ResolveInfo> list = packageManager. queryIntentActivities (intent, PackageManager. GET_ACTIVITIES); return list. size ()> 0 ;}

The following is the complete code and can be used directly:

Public class SetMiuiPermission {/*** jump to the application permission settings page http://www.tuicool.com/articles/jUby6rA * @ param context incoming app or activity context, get the application packegename through context, then, use packegename to redirect to determine whether the application * @ return is miui */public static boolean gotoPermissionSettings (Context context) {boolean mark = isMIUI (); if (mark) {// it is compatible with the miui v5/v6 application permission settings page. Otherwise, you will be redirected to the application settings page (the permission settings are on the previous page) try {Intent localIntent = new Intent ("miui. intent. action. APP_PERM_EDITOR "); localIntent. setClassName ("com. miui. securitycenter "," com. miui. permcenter. permissions. apppermissionseditequaltient "); localIntent. putExtra ("extra_pkgname", context. getPackageName (); context. startActivity (localIntent);} catch (ActivityNotFoundException e) {Intent intent = new Intent (Settings. ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri. fromParts ("package", context. getPackageName (), null); intent. setData (uri); context. startActivity (intent) ;}} return mark;}/*** check whether the phone is miui * @ ref http://dev.xiaomi.com/doc/p=254/index.html * @ return */public static boolean isMIUI () {String device = Build. MANUFACTURER; System. out. println ("Build. MANUFACTURER = "+ device); if (device. equals ("Xiaomi") {System. out. println ("this is a xiaomi device"); return true;} else {return false;}/*** determines whether it is miui V5/V6, old miui cannot be compatible with * @ param context * @ return */public static boolean isMIUIv5v6 (Context context) {boolean result = false; Intent localIntent = new Intent ("miui. intent. action. APP_PERM_EDITOR "); localIntent. setClassName ("com. miui. securitycenter "," com. miui. permcenter. permissions. apppermissionseditinclutivity "); if (isIntentAvailable (context, localIntent) {result = true;} return result ;} /*** check whether the activity * @ param context * @ param intent * @ return */private static boolean isIntentAvailable (Context context, Intent intent) {PackageManager packageManager = context. getPackageManager (); List <ResolveInfo> list = packageManager. queryIntentActivities (intent, PackageManager. GET_ACTIVITIES); return list. size ()> 0 ;}}
The above function entry is: gotoPermissionSettings. Pass in the context of the current application to the permission settings page of the current application.


Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

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.