public boolean onKeyDown(int KeyCode,KeyEvent event){

if(KeyCode == KeyEvent.KEYCODE_BACK){

new AlertDialog.Builder(this)

.setIcon(R.drawable.exit)

.setTitle(“退出吗?”)

.setMessage(“可以完全退出本应用!”)

.setPositiveButton(“是”, new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int which) {

Intent it=new Intent();

it.setClass(main.this, homeActivity.class);

main.this.startActivity(it);

finish();

}

})

.setNegativeButton(“否”, null)

.show();

return true;

}else{

return super.onKeyDown(KeyCode, event);

}

 

AndYou Studio原创文章,遵循CC协议转载请注明@ 转载自AndYou Studio

Advertisements