从service弹出系统级自定义提示框,可在任意页面弹出
2024-10-03 00:28:56
添加权限
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
// 显示系统级提示框(自定义布局)
private void showNoticeDialog(String titil, final String text) {
LayoutInflater inflaterDl = LayoutInflater.from(MyApplication.getContext());
RelativeLayout layout = (RelativeLayout) inflaterDl.inflate(R.layout.layout_dialog_red_pack, null);
final Dialog builder = new AlertDialog.Builder(this).create();
builder.setCanceledOnTouchOutside(false);
builder.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);//关键句
builder.show();
builder.getWindow().setContentView(layout);
final TextView textView = (TextView) layout.findViewById(R.id.red_tv_text);
textView.setText(titil);
final ImageView img = (ImageView) layout.findViewById(R.id.red_iv_img);
img.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
}
最新文章
- Ural-1146Maximum Sum-最大子矩阵
- jvm中的动态分派
- 自定义cell
- 【POJ】1062 昂贵的聘礼(spfa)
- javascript 深拷贝
- telnet登录路由器启动服务的shell脚本
- Junit单元测试学习笔记三
- jquery滚动条
- HDU2520 我是菜鸟,我怕谁
- 【HDOJ】3496 Watch The Movie
- boost::function实践——来自《Beyond the C++ Standard Library ( An Introduction to Boost )》
- 动态代理写connection连接池Demo
- 使用BurpSuite进行双文件上传拿Webshell
- Let&#39;sEncrypt 免费通配符/泛域名SSL证书添加使用教程
- .net 多线程之线程取消
- Solr DocValues详解
- 四则运算安卓版ver.mk2
- 解决Jquery向页面append新元素之后事件的绑定问题
- solrconfig.xml配置详解
- CSS Div固定在网页顶部、底部、左侧、右侧