Only one Looper may be created per thread
来源:互联网 发布:在线视频变速播放软件 编辑:程序博客网 时间:2024/05/20 06:31
at android.os.Looper.prepare(Looper.java:77)
at android.os.Looper.prepare(Looper.java:72)
at com.tele.test.MyHandlerTask$2.run(MyHandlerTask.java:36)
at com.tele.test.MyHandlerTask.testLooper(MyHandlerTask.java:40)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)
原因分析:
Looper has nothing to do with for loops. The Looper is the part of the Android system that controls the UI thread. There are several things that wont work without preparing the looper, but in general it is best to avoid Looper.prepare(); unless absolutly nessisary. It is far better to use the async doInBackground to perform data processing or other longer operations, and then update the UI with onPostExecute and onProgressUpdate.
In short, unless you are using the UI in some way, you don't need to call the Looper. If you find yourself having to call the Looper, you probably need to restructure how your background threads are working.
意思是说:一个线程只能有一个Looper.prepare的方法,而Looper.myLooper必须是在Looper.prepare之后才可以使用,因为Looper.prepare会new一个Looper。- 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: Only one Looper may be created per thread
- Only one SparkContext may be running in this JVM
- QUESTION 132 Only one LONG column can be used per table
- 解决IE浏览器的only one scriptx object can be used per browser window问题
- 解决IE浏览器的only one scriptx object can be used per browser window问题
- 解决IE浏览器的only one scriptx object can be used per browser window问题
- ORA-14460: only one COMPRESS or NOCOMPRESS clause may be specified
- IMPDP ORA-14460: only one COMPRESS or NOCOMPRESS clause may be specified
- IMPDP ORA-14460: only one COMPRESS or NOCOMPRESS clause may be specified
- Spark Q&A : Only one SparkContext may be running in this JVM
- 多线程服务器模型-one loop per thread
- Python SQLite3的问题sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in th
- JPA Multiple writable mappings exist for the field [{0}]. Only one may be defined as writable, all o
- JPA Multiple writable mappings exist for the field [{0}]. Only one may be defined as writable, all o
- Only MySqlParameter objects may be stored
- qml中的属性绑定与赋值
- Java如何读取properties文件
- JAVA 大数总结
- android环境下两种md5加密方式
- 渣渣上路,请问java如何在不规则窗体上添加组件?
- Only one Looper may be created per thread
- java修饰符,作用域,缺省作用域--转自http://blog.sina.com.cn/s/blog_7ffb8dd501011alw.html
- IK分词
- 程序中对密码进行加解密的C代码示例
- 数值的整数次方
- qml编程规范--名字(命名规范)
- leetcode || 86、Partition List
- 三维引擎设计-多线程渲染(平台API基础和封装大致框架)
- 找数算法笔记