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

我使用一些较旧的代码并在运行此方法时,我得到Looper.prepare()错误。 我不明白这条线是什么意思,但这是非常必要的。

总体程序:我有一个AsyncTask调用一个调用doBindService()的方法 – 来自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.(Handler.java:197) at android.os.Handler.(Handler.java:111) at com.servicenexus.ServiceNexus$1.(ServiceNexus.java:128) at com.servicenexus.ServiceNexus.(ServiceNexus.java:128) at com.servicenexus.rNOC.(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()似乎是一个非常详细的错误消息; 如果它在该特定行发生错误(我假设在那里创建了处理程序)并从堆栈跟踪判断,我建议在发生错误之前调用Looper.prepare()