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.
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. 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
<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"
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: