I manage an ONGOING notification from my application (not from a service).
When I kill application from task manager with \"End\" button, no
I would suggest You to use Deepti solution (https://stackoverflow.com/a/28584405/619673) which was
@Override
public void onTaskRemoved(Intent rootIntent) {
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.cancel(NOTIFICATION_ID);
}
However, he forget mention one thing. If Your connection to service was by call bindService(), onTaskRemoved() won't be trigged. To handle this You must connect with service by call startService() as in example below:
startService(new Intent(context, CustomerService.class));
Once You call it, You will be able catch onTaskRemoved().
Nothing stands in the way to call both methods startService() and somewhere further bindService().
I was basing on solution Service: onTaskRemoved not called if started with bindService
startService(new Intent(context, CustomerService.class)); // this will allow catch onTaskRemoved
// ...
bindService(new Intent(context, CustomerService.class),
mConnection, Context.BIND_AUTO_CREATE);