Reputation: 5840
I was wondering if there is an event that i can register in order to catch when the user closes an app(that is press back on the last activity or some thing of that kind).
Thanks
Upvotes: 0
Views: 68
Reputation: 369
if you are using a Service
maybe overriding onTaskRemoved
can be useful if you want to know that the user has removed your app from the recent task list.
Upvotes: 0
Reputation: 24998
In your MainActivity
, you can override onBackPressed()
to know when the user has pressed the back button and handle it appropriately.
Called when the activity has detected the user's press of the back key. The default implementation simply finishes the current activity, but you can override this to do whatever you want.
You can use this in conjunction with isTaskRoot()
to implement what you described.
Return whether this activity is the root of a task. The root is the first activity in a task.
Upvotes: 1
Reputation: 5227
I think this can be done by using a service and a broadcast receiver , Ensure if you really need these to fulfil the requirements you have.
Upvotes: 0