Android: Code To Handle Return Button Of The Softkey Or Return Button Which Is On Mobile
in my application I collect some data by the client. On the main layout.xml client put some data and in last they need to click on save button after that all the data will store in
Solution 1:
override the method onBackPressed inside your Activity to achieve this
@Override
public void onBackPressed() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure you want to exit?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
CustomTabActivity.this.finish();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
Post a Comment for "Android: Code To Handle Return Button Of The Softkey Or Return Button Which Is On Mobile"