I'm a student who's starting to develop an android application. I'd like to know about the exact time when a user exited an android application. I'd like to get some variables which contain that time information to make some notification. This is because, I'd like to notify them to click my application and start playing. Just like other game applications. Pleas help me out with example codes.
Asked
Active
Viewed 186 times
0
-
4Please explain **exactly** what you mean by "exit" in this context. – CommonsWare Jul 28 '15 at 10:47
-
If you mean that you want to know when the app goes to the background, this thread can be pretty useful for you http://stackoverflow.com/questions/4414171/how-to-detect-when-an-android-app-goes-to-the-background-and-come-back-to-the-fo – Daniel Julio Jul 28 '15 at 10:57
-
@CommonsWare exit meas user closed the application. – gravity Jul 28 '15 at 11:03
-
1@gravity That still doesn't exactly explain what you mean. The user can exit application but it can still be running in the background but not in the foreground. The user can also force stop the application which means it won't be running in the background. – Daniel Julio Jul 28 '15 at 11:48
3 Answers
1
This is my answer for exit the application
public void onbtnPressed(){
Toast.makeText(getBaseContext(), "Thank you...", Toast.LENGTH_SHORT).show();
finish();enter code here
}

Naveen Viswa
- 11
- 5
0
You can find using onUserLeaveHint method in Activity
@Override
protected void onUserLeaveHint(){
Toast.makeText(getApplicationContext(),"UserLeft",Toast.LENGTH_LONG).show();
super.onUserLeaveHint();
}

Jayadeep
- 329
- 1
- 2
- 10