简体   繁体   English

如何在MI 4i安全APP中以编程方式为我的应用启用自动启动选项?

[英]How to programmatically enable Autostart option for my app in MI 4i security APP?

For check screenshot and detail, click here 有关屏幕截图和详细信息,请单击此处

Please give related suggession or code for how to add automatic enable auto start for my app , please check here attached screen shot thanks in advance. 请提供相关的建议或代码,了解如何为我的应用添加自动启用自动启动,请在此处查看附带的屏幕截图。

Try this...it's working for me. 试试这个...它对我有用。 It will open the screen to enable autostart. 它将打开屏幕以启用自动启动。

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);
        }

Few OEMs including (RedMi) customizes the stack ROM for battery/memory optimization and have blocked the "onDestroy()" and "onTaskRemoved" callbacks. 很少有OEM(RedMi)定制堆栈ROM以进行电池/内存优化,并阻止了“onDestroy()”和“onTaskRemoved”回调。 As an user you can prevent the App's service from killing by locking the App. 作为用户,您可以通过锁定应用程序来阻止应用程序的服务被杀死。 Or, White listing the app by enabling "Autostart" setting for the App. 或者,白色通过启用应用程序的“自动启动”设置列出应用程序。 Programmatically you can prompt the user to enable the Autostart for the App Please find details here 以编程方式,您可以提示用户启用应用程序的自动启动请在此处查找详细信息

Please note: I have tested the Autostart enabling programatically on few devices but found that it does not works always. 请注意:我已经在少数设备上以编程方式测试了自动启动,但发现它始终无法正常工作。 Please check above link to see the possible options. 请查看上面的链接以查看可能的选项。

First of all you need a permission at the manifest: 首先,您需要在清单上获得许可:

 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

Still in manifest you need to add a brodcast receiver within your 仍然在清单中你需要在你的内部添加一个brodcast接收器

<application>

element: 元件:

<receiver android:name="net.example.MyOwnBroadcastReceiver">  
<intent-filter>  
    <action android:name="android.intent.action.BOOT_COMPLETED" />  
</intent-filter>  

after that in your Class "MyOwnBroadcastReceiver" 在你的班级“MyOwnBroadcastReceiver”之后

package net.example;

public class MyOwnBroadcastreceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Intent startServiceIntent = new Intent(context, MyService.class);
        context.startService(startServiceIntent);
    }
}

You can get more help on the following links: 您可以通过以下链接获得更多帮助:

http://blog.gregfiumara.com/archives/82 http://blog.gregfiumara.com/archives/82

http://techblogon.com/android-start-service-on-boot/ http://techblogon.com/android-start-service-on-boot/

暂无
暂无

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

相关问题 如何在Android中以编程方式在小米手机安全应用程序中为我的应用程序启用自动启动选项 - How to enable AutoStart option for my App in Xiaomi phone Security App programmatically in android 如何在小米设备中为我的应用启用自动启动 - How to enable autostart for my app in Xiaomi devices 当应用程序被杀死或在Mi 4i中强制停止时,android推送通知不起作用 - android push notification is not working when app Killed or force stop in Mi 4i 如何在三星设备中以编程方式启用自动启动选项? - How to Enable Autostart option programmatically in Samsung devices? 如何在ASUS zenfone2和其他ASUS型号中为我的应用程序启用自动启动选项 - How to enable autostart option for my app in ASUS zenfone2 and other ASUS models Android - 如何在小米设备中以编程方式启用自动启动选项? - Android - How to Enable Autostart option programmatically in Xiaomi devices? 如何在重启后在android中自动启动我的应用程序? - how can I autostart my app in android after reboot? 如何在Lenovo设备中以编程方式为我的应用启用自动启动选项? - how to programmatically enable Auto-start option for my app in Lenovo devices? 以编程方式将我的应用程序添加到 android 中的自动启动应用程序列表 - Add my app to AutoStart apps list in android programmatically 如何检查应用程序是MI安全权限自动启动中的白名单 - How to check application is white list in MI security permission autostart
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM