Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening miui battery saver for specific apps

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. enter image description here

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?

like image 970
Ifta Avatar asked Mar 24 '19 09:03

Ifta


People also ask

Does MIUI battery saver affect performance?

Turning battery saver on does not seem to have any noticable impact on performance at least. To test if it actually saves extra battery I let the battery drain from 100% to 8% with almost same usage profile.

Is it OK to turn on battery saver all the time on redmi?

There's no harm in using Battery Saver mode, but you do lose features while it's activated, including GPS and background syncing.


1 Answers

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) {
    }
like image 100
Mayank Sharma Avatar answered Oct 05 '22 04:10

Mayank Sharma