简体   繁体   English

线程化-无法在未调用Looper.prepare()的线程内创建处理程序

[英]Threading - Can't create handler inside thread that has not called Looper.prepare()

I am using some older code and in running this method, I get the Looper.prepare() error. 我正在使用一些较旧的代码,并且在运行此方法时,出现Looper.prepare()错误。 I don't understand what the line means but it is very necessary. 我不明白这条线是什么意思,但这是非常必要的。

Overall program: I have an AsyncTask that calls a method which calls doBindService()--from doInBackground()--. 总体程序:我有一个AsyncTask,该方法调用从doInBackground()-调用doBindService()的方法。 I have read the numerous other questions about this error and I guess I have a threading error but I can't figure out what the issue is. 我已经阅读了有关此错误的许多其他问题,并且我想我有一个线程错误,但是我无法弄清楚问题是什么。

public rNOC doBindService(){

         _server = new rNOC(this);//CODE FAILING HERE
        return _server;
        }


 *** Uncaught remote exception!  (Exceptions are not yet supported across processes.)
    java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
    at android.os.Handler.<init>(Handler.java:197)
    at android.os.Handler.<init>(Handler.java:111)
    at com.servicenexus.ServiceNexus$1.<init>(ServiceNexus.java:128)
    at com.servicenexus.ServiceNexus.<init>(ServiceNexus.java:128)
    at com.servicenexus.rNOC.<init>(rNOC.java:31)
    at com.servicenexus.ServiceNexus.doBindService(ServiceNexus.java:406)
    at com.servicenexus.ServiceNexus$2.login(ServiceNexus.java:790)
    at com.servicenexus.IRemoteInterface$Stub.onTransact(IRemoteInterface.java:126)
    at android.os.Binder.execTransact(Binder.java:351)
    at dalvik.system.NativeStart.run(Native Method)

java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() seems to be a pretty detailed error message; java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()似乎是一条非常详细的错误消息; if it errors at that particular line (I'm assuming the handler is being created there) and judging from the stack trace, I would suggest calling Looper.prepare() before the error occurs. 如果它在该特定行发生错误(我假设正在那里创建处理程序)并从堆栈跟踪中判断,我建议在发生错误之前调用Looper.prepare()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android线程错误-无法在未调用Looper.prepare()的线程内创建处理程序 - Android thread error - Can't create handler inside thread that has not called Looper.prepare() 无法在警告对话框线程中未调用Looper.prepare()的线程内创建处理程序 - Can't create handler inside thread that has not called Looper.prepare() on alert dialog thread 无法在未在AsyncTask for ProgressDialog中调用Looper.prepare()的线程内创建处理程序 - Can't create handler inside thread that has not called Looper.prepare() inside AsyncTask for ProgressDialog java.lang.RuntimeException:无法在尚未调用Looper.prepare()的线程内创建处理程序 - java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() java.lang.RuntimeException:无法在尚未调用 Looper.prepare() 的线程内创建处理程序错误 - java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() Error 无法在 AsyncTask 中未调用 Looper.prepare() 的线程内创建处理程序 - Can't create handler inside thread that has not called Looper.prepare() in AsyncTask 无法在未调用Looper.prepare()Android的线程内创建处理程序 - Can't create handler inside thread that has not called Looper.prepare() Android java.lang.RuntimeException:无法在未在Android中调用Looper.prepare()的线程内创建处理程序 - java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() in Android RxJava无法在未调用Looper.prepare()的线程内创建处理程序 - RxJava Can't create handler inside thread that has not called Looper.prepare() 警报对话框崩溃Android测试 - “无法在未调用Looper.prepare()的线程内创建处理程序” - Alert Dialog crashes Android test - “Can't create handler inside thread that has not called Looper.prepare()”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM