2013-08-27 103 views
0

我使用一些旧的代码和运行这个方法,我得到的Looper.prepare()错误。我不明白这条线的意思,但它是非常必要的。线程 - 无法创建内螺纹处理程序尚未调用Looper.prepare()

总体方案:我有一个调用它调用doBindService(方法)的的AsyncTask - 从doInBackground() - 。我已经阅读了关于这个错误的许多其他问题,我想我有一个线程错误,但我无法弄清楚是什么问题。

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) 

回答

0

java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()似乎是一个非常详细的错误信息;如果在那个特定的线路错误(我假设正在创建那里的处理程序),并从堆栈跟踪情况来看,我建议叫Looper.prepare()错误发生之前。

+0

而且,如文档中说,调用Looper.loop()在指令结尾与Looper.myLooper()+结尾。退出()。 – Sw4Tish

+0

在Looper.prepare()中添加工作。为什么这样做? – benzabill

+0

阅读文档... – Sw4Tish

相关问题