Context mContext=this;
AlertDialog d=null;
private void showSystemDialog() {
// TODO Auto-generated method stub
/* create ui */
AlertDialog.Builder b = new AlertDialog.Builder(mContext);
b.setTitle("warning").setMessage("Low of space,Please delete apps!");
b.setPositiveButton("uninstall apps", new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Intent intent = new Intent(Intent.ACTION_MANAGE_PACKAGE_STORAGE);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
});
b.setOnKeyListener(new OnKeyListener() {
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if(keyCode==KeyEvent.KEYCODE_HOME||keyCode==KeyEvent.KEYCODE_BACK){
d=null;
}
return false;
}
});
d = b.create();
d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
// d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY);
d.show();
/* set size & pos */
WindowManager.LayoutParams lp = d.getWindow().getAttributes();
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
if (display.getHeight() > display.getWidth()) {
// lp.height = (int) (display.getHeight() * 0.5);
lp.width = (int) (display.getWidth() * 1.0);
} else {
// lp.height = (int) (display.getHeight() * 0.75);
lp.width = (int) (display.getWidth() * 0.5);
}
d.getWindow().setAttributes(lp);
}