Android Question Closing Notification If App Is Killed

Discussion in 'Android Questions' started by HimeAnator, Feb 23, 2015.

  1. HimeAnator

    HimeAnator Member Licensed User

    I created an app that upon pressing a start button the app then creates a notification letting the user know the app is running. I noticed however that if the user were to kill the application by swiping it away in the task bar then the notification is not closed. Is there a way to cancel the notification if the app is closed altogether? I still want the user to have the ability to leave my app such as go to home the screen and leave it running in the background, I just want cancel the notification only if the app have been totally closed. Can I somehow check if the app closed from the service running my notification and if so then cancel it?
  2. KZero

    KZero Active Member Licensed User

    -i think the notification should be canceled automatically if the app closed
    however you can try to cancel it manually before closing the app
    n.OnGoingEvent =False

    - swiping the notification away will not close the application

    -you can check if an activity is active or paused using
  3. HimeAnator

    HimeAnator Member Licensed User

    Thank you for the reply KZero, basically what I'm trying to do is detect if the app has been killed from the task manager. My app performs calculations in the background so I'm ok with the user having the ability to tap the home or back button to go to their home screen or something like that while the app is still open in the background. The problem is if the user forces my app to close by killing it in the task manager then the app and background calculations cease and they are still left with a notification saying that the app is running when actually its not. When the user kills an app that way I don't think any of the events are triggered, the app is just stopped dead in its tracks. If the user causes the application to pause that is fine, my calculations are still performed. I'm trying to detect whether the app has been closed altogether. Thinking this needs to be done in the notification service module :/
  4. DT1111

    DT1111 Member Licensed User

    HimeAnator, I have a similar situation and I am curious if you have had closure or solution to the above issue?
  5. Erel

    Erel Administrator Staff Member Licensed User

    You cannot do anything when the process is killed from the task manager. It is killed immediately.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice