简体   繁体   中英

How to check application is white list in MI security permission autostart

I am building an android application where I am using some services. My services get close when application is close in some custom android OS like MI.

Then I figure out we have to push our application in white list of security autostart application.

I got some SOF link's where they are suggesting below answer.

String manufacturer = "xiaomi";
    if(manufacturer.equalsIgnoreCase(android.os.Build.MANUFACTURER)) {
        //this will open auto start screen where user can enable permission for your app
        Intent intent = new Intent();
        intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"));
        startActivity(intent);
    }

This above code used to send user to that particular page.

Now I have to check if my application is disable so I can send user to this page and if it is enable then move to other screen. Is there any way to check this?

There is no Android API to check if the the AutoStart is enabled or not. Though you can have your own logic in the App (may be you can use preference to set a Boolean for it) to check this. Also the above way to enabling the AutoStart might not work always. Please have a look here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM