Friday, April 15, 2011

How to Back Press Key in Android

@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if ((!(android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.DONUT)
&&keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0))
{
onBackPressed();
}
return super.onKeyDown(keyCode, event);
}

public void onBackPressed()
{
finish();
}

No comments:

Post a Comment