Android 系统是否要重启时弹出框

void  dialogExit(Context context){
    	final PowerManager manager = (PowerManager)getSystemService(Context.POWER_SERVICE);
    	AlertDialog.Builder builder = new Builder(context);
    	builder.setMessage(R.string.comfirm_restart);
    	builder.setTitle(R.string.prompt);
    	builder.setPositiveButton(R.string.ok,new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				 manager.reboot("restart");
			}
		});
    	builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				dialog.dismiss();
				
			}
		});
    	builder.create().show();
    	
    }

PowerManager是系统内代码,其中 manager.reboot("restart");就可以实现重启

你可能感兴趣的:(android,弹出框)