Reputation: 14370
I need to know if we press home or back button in android... can we close the application activity? If not than how can we know that the app activity is running or not?
Upvotes: 2
Views: 228
Reputation: 2250
You can close application when You press the home or back button.
try this code
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(KeyEvent.KEYCODE_BACK==keyCode || KeyEvent.KEYCODE_HOME==keycode)
{
finish();
}
return super.onKeyDown(keyCode, event);
}
Upvotes: 1