如何在service中显示对话框dialog
2016-10-09 10:14
357 查看
AlertDialog.Builder b = new AlertDialog.Builder(StatusBarService.this); b.setView(view); final AlertDialog d = b.create(); d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG); //系统中关机对话框就是这个属性 //d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); //窗口可以获得焦点,响应操作 //d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY); //窗口不可以获得焦点,点击时响应窗口后面的界面点击事件 d.show(); Button yesButton = (Button) view.findViewById(R.id.yes_button); Button canclButton = (Button) view.findViewById(R.id.cancl_button); yesButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN); intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }); canclButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { d.dismiss(); } });
相关文章推荐
- 如何使用Service的Context弹出Dialog对话框,即全局性对话框
- 如何在service中显示Dialog
- 如何在服务(Service)程序中显示对话框
- 如何在服务(Service)程序中显示对话框
- How to show a modal dialog and modeless dialog using C++ - 如何用C++显示一个模态对话框和一个非模态对话框
- 如何在服务(Service)程序中显示对话框
- 如何在服务(Service)程序中显示对话框
- 如何在服务(Service)程序中显示对话框(转贴)
- 如何在服务(Service)程序中显示对话框
- service中显示一个dialog
- 修改 android Dialog 对话框显示的位置
- Android如何将Activity以Dialog的形式显示
- 如何在 对话框 启动时 实现隐藏窗口(只显示托盘)
- MFC如何使dialog对话框置顶
- zt:如何显示中文化的打印设置对话框?
- Service如何弹出dialog
- VC6对话框中,如何实现点击一个按钮,在相应的Edit框里,显示当前时间
- android在Service中弹出Dialog对话框,即全局性对话框
- 模态对话框/非模态对话框/系统对话框CColorDialog 置顶问题/显示最前面/TopMost
- 如何在Bash Shell脚本中显示对话框