Opening miui battery saver for specific apps

試著忘記壹切 提交于 2021-01-04 06:57:05

问题


I am working on VoIP calling applications and calls are getting missed which are sent over FCM when battery saver is on on MIUI. This is happening very frequently.

I want user to open Battery saver activity for my own app and give no restriction for that app in battery saver.

For example: this is a the battery saver page for whatsApp.

I want to open this page directly for my app from my app.

I have managed to enable autostart in the shown way. How to check MIUI autostart permission programmatically?


回答1:


After checking logs for the MiFit app, I finally figured it out!

It took almost 3 days of continuous research. Pheww, here is the code.

try {
        Intent intent = new Intent();
        intent.setComponent(ComponentName("com.miui.powerkeeper", "com.miui.powerkeeper.ui.HiddenAppsConfigActivity"));
        intent.putExtra("package_name", getPackageName());
        intent.putExtra("package_label", getText(R.string.app_name));
        startActivity(intent);
    } catch (ActivityNotFoundException anfe) {
    }

Mayank Sharma - A Google Certified Android App Developer



来源:https://stackoverflow.com/questions/55322529/opening-miui-battery-saver-for-specific-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!