线程 - 无法创建内螺纹的处理程序已经不叫尺蠖prepare()。 [英] Threading - Can't create handler inside thread that has not called Looper.prepare()
问题描述
我使用一些旧的code和运行这个方法,我得到的活套。prepare()错误。我不明白什么是行的意思,但它是非常必要的。
总体方案:我有一个调用它调用doBindService(方法)的AsyncTask的 - 从doInBackground() - 。我看了一下这个错误的许多其他问题,我想我有一个线程错误,但我想不出是什么问题。
公共rNOC doBindService(){ _ SERVER =新rNOC(本); // code失败HERE
返回_SERVER;
}
***未捕获远程异常! (异常不跨进程尚不支持。)
了java.lang.RuntimeException:无法内螺纹已不叫尺蠖prepare创造处理器()
在android.os.Handler<&初始化GT;(Handler.java:197)
在android.os.Handler<&初始化GT;(Handler.java:111)
在com.servicenexus.ServiceNexus $ 1<&初始化GT;(ServiceNexus.java:128)
在com.servicenexus.ServiceNexus<&初始化GT;(ServiceNexus.java:128)
在com.servicenexus.rNOC<&初始化GT;(rNOC.java:31)
在com.servicenexus.ServiceNexus.doBindService(ServiceNexus.java:406)
在com.servicenexus.ServiceNexus $ 2.login(ServiceNexus.java:790)
在com.servicenexus.IRemoteInterface $ Stub.onTransact(IRemoteInterface.java:126)
在android.os.Binder.execTransact(Binder.java:351)
在dalvik.system.NativeStart.run(本机方法)
了java.lang.RuntimeException:无法内螺纹创建的处理程序已经不叫尺蠖prepare()
似乎是pretty详细的错误信息;如果错误在那个特定的行(我假设正在创建那里的处理程序),并从堆栈跟踪情况来看,我建议叫活套。prepare()
错误发生前。
I am using some older code and in running this method, I get the Looper.prepare() error. 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()--. 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; 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.
这篇关于线程 - 无法创建内螺纹的处理程序已经不叫尺蠖prepare()。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!