-1

I've been using onTaskRemoved() method in a Service to detect when an app was removed from the device's RECENT list by swiping it away. I preform some logging and some other operations that need to take place when this happens. It works perfectly. For android below 6... But background service is being killed after swiping off in android 6.

     @Override
        public void onTaskRemoved(Intent rootIntent) {
            Log.e("ClearFromRecentSsss", "sttttts");
         Intent intent = new Intent("in.com.example");
            sendBroadcast(intent);           
        }
Red fx
  • 1,071
  • 2
  • 12
  • 26
Abhishek
  • 11
  • 6

1 Answers1

1

Some manufactures like xiaomi, Oppo have their own background strategy which is autostart. You need to redirect user to auto start activity and tell user to switch on: Go like this and allow your app to autostart:

Settings > permissions > Autostart

Autostart setting varies by manufactures like in Xiaomi you can find it in their SecurityCenter app. Autostart is blocking your service to restart, So turn it on manually and the check again . I'm afraid there is no inbuilt API to do so . So you need to redirect users to specified screen as per manufactures to turn auto start On. Have a look at Links below:

  1. link1

  2. link2

ADM
  • 20,406
  • 11
  • 52
  • 83