Background Service Has Stopped On Miui Rom
I am developing a background services and in OnDestroy Method, I've called an intent to start my services again. I'ts not started again on miui rom (Xiaomi mobile and huawei mobile
Solution 1:
It doesn't new on Xiaomi because Xiaomi has a feature called app permission, where user has to allow the app to start automatically (Service).
Go like this and allow your app to autostart:
Settings > permissions > Autostart
Or,
Don't try to restart the same Service inside onDestroy() instead use START_STICKY inside onStartCommand(Intent intent, int flags, int startId) method.
Again you are sending broadcast not starting a service, Use onDestroy properly:
@OverridepublicvoidonDestroy() {
Intentintent=newIntent("example.app.start");
sendBroadcast(intent);
super.onDestroy();
}
Post a Comment for "Background Service Has Stopped On Miui Rom"