android面试题-Service中弹出Dialog
来源:互联网 发布:网络延时英文 编辑:程序博客网 时间:2024/06/05 20:57
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.setMessage("有新消息,是否查看?"); alertDialog.setPositiveButton("否", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); alertDialog.setNegativeButton("是", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); ad = alertDialog.create(); ad.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); ad.setCanceledOnTouchOutside(false);//点击外面区域不会让dialog消失 ad.show();
添加权限
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (!Settings.canDrawOverlays(this)) { Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName())); startActivityForResult(intent, 1); }}
@Overrideprotected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (!Settings.canDrawOverlays(this)) { // SYSTEM_ALERT_WINDOW permission not granted... } } }}
阅读全文
0 0
- android面试题-Service中弹出Dialog
- android在Service中弹出Dialog对话框
- Android在Service中弹出对话框(Dialog)
- Android在Service中弹出Dialog
- android service中弹出dialog对话框
- Service中弹出Dialog Toast
- android在Service中弹出Dialog对话框,即全局性对话框
- android在Service中弹出Dialog对话框,即全局性对话框
- android在Service中弹出Dialog对话框,即全局性对话框
- android在Service中弹出Dialog对话框,即全局性对话框
- android在Service中弹出Dialog对话框,即全局性对话框
- Android在Service中弹出对话框(Dialog),即全局性对话框
- android在Service中弹出Dialog对话框,即全局性对话框
- android在Service中弹出Dialog对话框,即全局性对话框
- android在Service,BroadCast onReceiver()中弹出Dialog对话框
- android在Service,BroadCast onReceiver()中弹出Dialog对话框
- android在Service中弹出Dialog对话框,即全局性对话框
- android在Service中弹出Dialog对话框,即全局性对话框
- Android学习路线指南
- pandas.Series函数用法
- 微信小程序开发一swiper轮播图的简单实现
- 有刷直流电机H桥功率驱动电路的设计心得
- SQL Server 全文索引的硬伤
- android面试题-Service中弹出Dialog
- Linuxf服务器动态生成Android带标识的自定义APP打包
- 微信小程序tabBar 不显示底部菜单的原因和解决方法
- linux 新建用户、用户组 以及为新用户分配权限
- leetcode 第18题 4Sum
- splice/slice/split的区别
- 2.编译器
- 数据仓库系统的实现与使用(含OLAP重点讲解)
- Smart