3

I am facing one problem when i kill application from background.My application is closed but the notification from the status bar is still there. How can we remove the notification from status bar when my application kill from background . Can we get the event when user kill the application from background ?

Thanks in advance.

GOLDEE
  • 2,318
  • 3
  • 25
  • 49
sanni
  • 89
  • 5
  • Are you sure that your application is killed? As far as I know, if an application is killed, the notifications go off too. – Nitin Sethi Dec 18 '13 at 15:04
  • Yes i am sure. I press home button and swipe app .and when i again launch app it will open from start means like fresh app. – sanni Dec 19 '13 at 07:03
  • Swiping an app away from recents task list doesn't mean killing it I suppose. How about trying to force stop it from Settings page and see if the notifications go or not? – Nitin Sethi Dec 19 '13 at 17:34

3 Answers3

0

try your code to remove the notification in the OnDestroy() method of your application class.

    class myApplication extends Application{
    @Override
    public void onTerminate() {
        // remove notification code here
        super.onTerminate();
    }
}

NOT TESTED, BUT GIVE A TRY

AabidMulani
  • 2,325
  • 1
  • 28
  • 47
0

It won't work because notifications is not a part of your app's process. You just send it to the notification service and it shows them.

To hide notifications you should cancel it in your program before destroying.

Also android should not notify your application. It can just kill it without any callbacks.

wnc_21
  • 1,751
  • 13
  • 20
-1

In onDestroy() cancel the notification

Abhishek
  • 39
  • 6