4

Android Service onTaskRemoved() is not called on Device ,But works on Emulator Genymotion

 @Override
public void onTaskRemoved(Intent rootIntent) {

    Toast.makeText(getBaseContext(), "TASK ON REMOVE ", Toast.LENGTH_LONG).show();
    Intent restartServiceIntent = new Intent(getApplicationContext(),
            this.getClass());
    restartServiceIntent.setPackage(getPackageName());

    PendingIntent restartServicePendingIntent = PendingIntent.getService(
            getApplicationContext(), 1, restartServiceIntent,
            PendingIntent.FLAG_ONE_SHOT);
    AlarmManager alarmService = (AlarmManager) getApplicationContext()
            .getSystemService(Context.ALARM_SERVICE);
    alarmService.set(AlarmManager.ELAPSED_REALTIME,
            SystemClock.elapsedRealtime() + 1000,
            restartServicePendingIntent);

    super.onTaskRemoved(rootIntent);
}

Emulator Genymotion Android 6.0 , Device Huawei android 6.0

Help me. Thank you.

Manohar
  • 22,116
  • 9
  • 108
  • 144
  • 2
    I am facing the same issue with lenovo mobiles.. were u able to solve it? – Rahul Hawge Feb 08 '17 at 09:28
  • 1
    Possible duplicate of [onTaskRemoved() not getting called in HUAWEI and XIOMI devices](http://stackoverflow.com/questions/40660216/ontaskremoved-not-getting-called-in-huawei-and-xiomi-devices) – Yoni Gross Feb 13 '17 at 01:52
  • 2
    Does anyone got any solution for that . i am busting my ass on this problem for almost 2 days . – ADM Feb 23 '17 at 13:45
  • 1
    @ADM now busting me too.. pls help me out.. any solution for this – Ranjithkumar Mar 25 '18 at 18:34

0 Answers0