Reputation:
Hi I have written the following code:
public boolean onKeyDown(int keyCode,KeyEvent event) {
if (keyCode==KeyEvent.KEYCODE_HOME) {
showDialog(MY_DALOG);
return true;
}
return true;
}
But when I press the HOME BUTTON
, it doesn't call the line if(keyCode==KeyEvent.KEYCODE_HOME)
when debugging.
On the other hand, it calls the onPause()
. I have put my code in onPause()
but still, it shows a SuperNotFound
exception in Logcat.
Any idea how to display a dialog
by pressing the HOMEKEY
?
Upvotes: 1
Views: 502
Reputation: 19500
KeyEvent.KEYCODE_HOME is not for the developers. Android has made it safe for themselves. So that no application would force the user to stay inside their application.
Upvotes: 2
Reputation: 19800
The Home Button
will be handled by the PhoneWindowManager
in the Android framework
. It will be sent to the Launcher
application.
No other application will receive it in their Activity.
Upvotes: 3
Reputation: 3481
This is actually possible. But you have to make your own 'home screen replacement' app, and let the user set your app as the user's new home screen. But this is probably a much more complicated solution than what you are looking for...
Upvotes: 0
Reputation: 4017
Sorry. you can show alert dialogue by pressing back button
of device.
But, you can't implement those feature with HOME Button
pressed. Because, Android is designed as automatically launch home page
without consider about anything happening right now on UI, While pressing it.
Upvotes: 0