I am new to android development. I am working on a android app.
Can anyone say me how to call a particular method in android, when an user kill or terminate my app. In other words, I need to execute a particular method first when user kills/terminate my app from their mobile. So that, the specific method will be executed first and then my app will be closed.
Any suggestions please. Thank you.
This is possible by overriding the
onStoporonDestroymethods of yourActivity.Like this:
onStopgets called just before the user exits the activity , or when another activity starts pushing this one in the background.onDestroygets called just before you completely finish the activity by calling Activity.Finish(), or when the system has to remove it from the memory to save space.For more info about the application lifecycle , see here.