The onTaskRemoved service is not called when the application starts on any device

I override onTaskRemovedin mine Service, but it never gets called when I kill the application on the device Xiaomi, but in SamSung, Sonyit gets called normally. (I do not install ServiceInfo.FLAG_STOP_WITH_TASKfor my service)

public class MyService extends Service {

    @Override
    public void onTaskRemoved(Intent rootIntent) {
         super.onTaskRemoved(rootIntent);
         Toast.makeText(this,"onTaskRemoved",Toast.LENGTH_SHORT).show();
         Log.i("TAG", "Task removed");
    }
}

I need to determine when the service will stop starting again, because it START_STICKYdoes not work as my question is here

How can I handle this case. Any help or suggestion would be greatly appreciated?

+2
source share

Source: https://habr.com/ru/post/1666686/


All Articles