覆蓋你的活動裏面的方法onBackPressed實現這一
@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();
}
感謝名單Waqas .... 我有更多的一個問題。 也請給出一些關於這個問題的想法: http://stackoverflow.com/questions/8951236/android-return-button-not-work-when-camera-mode-is-open –