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
It is been handled here in the file Cocos2dxGLSurfaceView.java
change it to below, where myActivity
is the cocos2dActicity
case KeyEvent.KEYCODE_BACK:
AlertDialog ad = new AlertDialog.Builder(myActivity)
.setTitle("EXIT?")
.setMessage("Do you really want to exit?")
.setPositiveButton("YES", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
((Cocos2dxActivity)myActivity).finish();
}
})
.setNegativeButton("NO", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
}).create();
ad.show();
return true;
case KeyEvent.KEYCODE_MENU: