How to handle Home Button in device as well as in emulator.
i found these two methode's:-
public void onPause
public void onStop
but according to my needs this in not perfect solution for that. any one guide me.
How to handle Home Button in device as well as in emulator.
i found these two methode's:-
public void onPause
public void onStop
but according to my needs this in not perfect solution for that. any one guide me.
I found the solution:-
public void onUserLeaveHint()
{
super.onUserLeaveHint();
}
Only executed when HOME button pressed.
more detail see http://developer.android.com/reference/android/app/Activity.html
See, for security reasons android developers itself are not allowing us to change any kind of behaviour wiht home button. But even though if you really want to disable the home button press you can do this by adding below code ....
@Override
public void onAttachedToWindow() {
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_HOME) {
Log.i("Home Button","Clicked");
}
if(keyCode==KeyEvent.KEYCODE_BACK) {
finish();
}
return false;
}