简体   繁体   English

如何检查应用程序是MI安全权限自动启动中的白名单

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

I am building an android application where I am using some services. 我正在构建一个Android应用程序,我正在使用一些服务。 My services get close when application is close in some custom android OS like MI. 当应用程序在MI等一些自定义Android操作系统中关闭时,我的服务就会关闭。

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. 我得到了一些SOF链接,他们建议在下面回答。

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. 没有Android API来检查是否启用了AutoStart。 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. 虽然您可以在App中拥有自己的逻辑(可能是您可以使用首选项为它设置布尔值)来检查它。 Also the above way to enabling the AutoStart might not work always. 此外,启用AutoStart的上述方法可能无法始终有效。 Please have a look here 请看这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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