I have an android application in which i want to exit the application only on device back key press.I mean that if user clicks on HOME button, I want to exit from the app but relaunch the app after a specific time. How to achieve this?
Asked
Active
Viewed 752 times
0
-
2when you press home button the application goes to the backgrond not exits. (excpet special cases). What do you exactly want – stinepike Mar 21 '13 at 04:13
-
I wan to make if my application goes to background on HOME button click, make the app forward.ie,I want to make the application exit only on BACK button click. – Devu Soman Mar 21 '13 at 04:16
-
@Devu :still its not clear ? – Kiran Mar 21 '13 at 04:43
1 Answers
0
If you want the application to be relaunched you can start a service and in that service you can start your activity using the code :
Intent dialogIntent = new Intent(getBaseContext(), myActivity.class);
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(dialogIntent);
You can set a flag when the home key is pressed and can check in service to ensure that the application is in background, so that activity is not relaunched unnecessarily.
This link might be helpful to you : Link

Community
- 1
- 1

Sanober Malik
- 2,765
- 23
- 30