MIUI App permissions settings

Source: Internet
Author: User

With the MIUI more and more closed, Xiaomi's use of non-free channel restrictions more and more stringent, our company's products more than half of the users are from Xiaomi, and like us to pay by text messages to maintain the revenue of the game, SMS permission is the default ban really to our lives. The game that is added to the MIUI blacklist is disabled by default, such as sending SMS permission by default to prohibit the direct disconnection of our revenue source. So it took a few hours to search the web for information, we couldn't help users open the app at least we were able to direct the user to open the app permissions, and would be guided as easily as possible.


data one: jump MIUI App permissions Settings page (compatible with v5/v6 old version only jump to the first level interface can be) Http://www.tuicool.com/articles/jUby6rA

Data Two: determine whether the current device is millet http://dev.xiaomi.com/doc/p=254/index.html

Data Three: Complete demo http://download.csdn.net/detail/tgbus18990140382/893288 1


Other nonsense also not much to say, directly on the code

First go through the context to the corresponding app's permission settings page:

/** * Jump to App permissions Settings page Http://www.tuicool.com/articles/jUby6rA  * @param context incoming app or activity context, Use the context to get the app Packegename, then use the packegename jump to make the app * @return is MIUI */public static Boolean gotopermissionsettings ( Context context) {Boolean Mark = Ismiui (); if (mark) {///is compatible with MIUI V5/v6  's app Rights Settings page, otherwise jump to app Settings page (permission set upper level page) try {Intent L Ocalintent = new Intent ("Miui.intent.action.APP_PERM_EDITOR"); Localintent.setclassname ("Com.miui.securitycenter", "Com.miui.permcenter.permissions.AppPermissionsEditorActivity"); 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;}


again is to determine whether it is millet equipment, the official provides us with a simple and convenient way:
/** * Check if the phone is MIUI * @ref http://dev.xiaomi.com/doc/p=254/index.html * @return */public static Boolean Ismiui () {String Devi CE = build.manufacturer; System.out.println ("build.manufacturer =" + device), if (Device.equals ("Xiaomi")) {System.out.println ("This is a XI Aomi device "); return true;} Else{return false;}}

We can also use a similar way to find activtiy to determine whether it is MIUI, but this approach also has a compatibility problem, not very recommended, also attached to the code for your reference:

/** * Determine if it is MIUI v5/v6, old miui Incompatible * @param context * @return */public static Boolean ismiuiv5v6 (Context context) {Boolean r Esult = false;intent localintent = new Intent ("Miui.intent.action.APP_PERM_EDITOR"); Localintent.setclassname (" Com.miui.securitycenter "," com.miui.permcenter.permissions.AppPermissionsEditorActivity "); if (Isintentavailable ( Context, localintent)) {result = true;} return result;} /** * Check if there is activity * @param context * @param intent * @return */private Static Boolean isintentavailable (context Contex T, 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 that can be used directly by the class:

public class Setmiuipermission {/** * jump to App permissions Settings page Http://www.tuicool.com/articles/jUby6rA * @param context incoming app or Activ ity context, get app packegename through context, then make app through Packegename jump * @return is MIUI */public static Boolean Gotopermissionsettings (Context Context) {Boolean Mark = Ismiui (); if (mark) {//Is compatible with MIUI V5/V6 's app Rights Settings page, otherwise the Jump App Settings page (permission set Place a first page) try {Intent localintent = new Intent ("Miui.intent.action.APP_PERM_EDITOR"); Localintent.setclassname (" Com.miui.securitycenter "," com.miui.permcenter.permissions.AppPermissionsEditorActivity "); 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 if 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 XI Aomi device "); return true;} Else{return false;}} /** * Determine if it is MIUI v5/v6, old miui Incompatible * @param context * @return */public static Boolean ismiuiv5v6 (Context context) {Boolean r Esult = false;intent localintent = new Intent ("Miui.intent.action.APP_PERM_EDITOR"); Localintent.setclassname (" Com.miui.securitycenter "," com.miui.permcenter.permissions.AppPermissionsEditorActivity "); if (Isintentavailable ( Context, localintent)) {result = true;} return result;} /** * Check if there is activity * @param context * @param intent * @return */private Static Boolean isintentavailable (context Contex T, Intent Intent) {Packagemanager Packagemanager = Context.getpackagemanager (); list<resolveinfo> list = Packagemanager.queryintentactivities (intent, packagemanager.get_activities); return List.size () > 0;}}
the entry for the above function is: gotopermissionsettings, the context of the current application is passed to the current app's permission settings page.


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

MIUI App permissions settings

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.