Remove notification from status bar when app kill from background

2k views Asked by At

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.

3

There are 3 answers

0
wnc_21 On

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.

0
Abhishek On

In onDestroy() cancel the notification

5
AabidMulani On

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