I am using cocos2dx to make a small game and in the activity of my game i give the following functions to handle back button.
@Override
public boolean onKeyDown
Just your apps implements for override method for onKeyDown,
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if (keyCode == KeyEvent.KEYCODE_BACK) {
// Here to implements for your code.
Log.d(TAG, "KEYCODE_BACK");
}
return super.onKeyDown(keyCode, event);
}