java.lang.RuntimeException: Only one Looper may be created per thread
来源:互联网 发布:linux 字符集设置 编辑:程序博客网 时间:2024/05/21 15:35
开发笔记:在service中弹dialog
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()出现这个错误
最后是看这个朋友的才弄好:http://blog.csdn.net/a740169405/article/details/11720585
调用系统权限:
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /><uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />
service中的代码:
new Thread(){ public void run() { Looper.prepare(); LayoutInflater inflater = (LayoutInflater) mContext .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View alert_view=inflater.inflate(R.layout.custom_alert_dialog,null); Button alert_assign= (Button) alert_view.findViewById(R.id.alert_assign); alert_cancel = (Button) alert_view.findViewById(R.id.alert_cancel); TextView alert_message = (TextView) alert_view.findViewById(R.id.alert_message); alert_message.setText(message); countTimer = new CountTimer(15000,1000); final AlertDialog.Builder builder = new AlertDialog.Builder( mContext);// Builder,可以通过此builder设置改变AleartDialog的默认的主题样式及属性相关信息 builder.setView(alert_view); alert_assign.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { cancle();// 当取消对话框后进行操作一定的代码?取消对话框 } }); alert_cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { cancle(); } }); alertDialog = builder.create(); alertDialog.setCancelable(false); alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); alertDialog.show(); countTimer.start(); Looper.loop(); } }.start();}调用系统的dialog要设置:
alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
阅读全文
0 0
- java.lang.RuntimeException: Only one Looper may be created per thread
- Only one Looper may be created per thread
- Only one Looper may be created per thread
- 【遇见Android bug】Only one Looper may be created per thread
- java.lang.RuntimeException: Errors accessing files. There may be spaces in your image's filename.
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- Android 异常 java.lang.RuntimeException: Can't create handler inside thread that has not called Looper
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- Android-java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.pr
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has notcalled Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- Android java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.pr
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- sftp put: failed to upload D:/XXXX/XXXX.war. Failure
- 解决eclipse没有断点却在有异常时跳到debug模式界面的问题
- csdn如何转载别人的文章
- 存储过程参考
- ubuntu14.04编译安装opencv3.2.0
- java.lang.RuntimeException: Only one Looper may be created per thread
- Struts2批量上传文件
- 23设计模式彩图
- Nginx配置基于ip的虚拟主机
- 来自一个小白学习PHP的学习路径
- myeclipse2013 git插件安装
- js java 保留 n 位小数
- 点击某个按钮切换图片(按钮颜色跟着改变)
- android 将文件下载到指定目录