I'm facing issue in cancelling ongoing notification from notification bar. It's working perfectly on previous versions of android using onTaskremoved()
in Service,but not in Oreo. I just need to cancel notification when app is force closed from recent apps.
Please let me know if any one have solution for this.
Previous versions
Asked
Active
Viewed 240 times
-1

Bineesh P Babu
- 268
- 1
- 14
-
I just need to cancel notification when app is cleared from OS. Do you mean clear from Recent Apps? – touhid udoy Dec 29 '18 at 08:04
-
Yes. From recent apps – Bineesh P Babu Dec 29 '18 at 08:14
1 Answers
2
UPDATE
If you force close your app, onDestroy will not be called and you have no option to intercept this action.
Here and Here are two references about it, you can find much more
....................
Add Those line inside in you service
@Override
public void onDestroy() {
super.onDestroy();
stopForeground(true);
}

touhid udoy
- 4,005
- 2
- 18
- 31
-
1
-
you updated you question. There was no mention of force close previously. If you force close your app, `onDestroy` will not be called and you have no option to intercept this action – touhid udoy Dec 29 '18 at 09:20
-
understood :). thanks for the response. if you have an answer for this, pls share it – Bineesh P Babu Dec 29 '18 at 09:24