Stop Service on Application Stopage

17 views
Skip to first unread message

niidark...@gmail.com

unread,
Jun 27, 2020, 11:03:35 PM6/27/20
to DroidScript
Hello gentlemen, I want a code that tells me when the app closes. I basically need that to stop the service. Thanks.

Alan Hendry

unread,
Jun 28, 2020, 11:33:58 AM6/28/20
to DroidScript
Hi,
There are 3 standard events, OnBack, OnPause, OnResume.
You can EnableBackKey(false), and have your own SetMenu with an exit routine
There's also app.Exit
Regards, ah

Nii Darku

unread,
Jun 28, 2020, 3:33:59 PM6/28/20
to DroidScript
That's fine reply Alan.

Let me put it this way..
If a user swipes away my app to close it, I want to detect that swipe as an exit.

We are all aware of how to tap the application listing key on a phone to display all running apps and then swipe away whichever app you wish to close.
Or even tap the close all key...

This is where I want to intercept the closure of my app and stop my service.

Any help guys?

Steve Garman

unread,
Jun 28, 2020, 4:54:18 PM6/28/20
to DroidScript
It looks like your requirements might be met by
stopping the service in OnPause() or when using app.Exit

and
starting the service at normal start and OnResume

If that doesn't fit your requirements, you might have to poll regularly from the service and shut down if you don't get a response from the app

It is possible to write code for the service to check directly whether the main app is running but the code is not obvious.

Nii Darku

unread,
Jun 28, 2020, 5:03:48 PM6/28/20
to DroidScript
Thank you Steve for the ideas.
I will find time to implement and get you feedback.
Reply all
Reply to author
Forward
0 new messages