备份之用:
public void showSystemDialog(String showInfo, final int flag)
{
AlertDialog.Builder b = new AlertDialog.Builder(context);
b.setMessage(showInfo);
b.setPositiveButton("确定", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
switch (flag)
{
case 0:
Intent intent = new Intent(
Settings.ACTION_WIRELESS_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
break;
case 1:
case 3: // 如果是GPRS,则提醒
if (moblieFlag == false)
{
moblieFlag = true;
}
default:
break;
}
d.dismiss();
}
}).setNegativeButton("取消", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
d.dismiss();
}
});
d = b.create();
d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
d.show();
WindowManager.LayoutParams lp = d.getWindow().getAttributes();
WindowManager wm = (WindowManager) context
.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
if (display.getHeight() > display.getWidth())
{
lp.width = (int) (display.getWidth() * 1.0);
}
else
{
lp.width = (int) (display.getWidth() * 0.5);
}
d.getWindow().setAttributes(lp);
}