我正在尝试将 a 附加SpiceManager
到服务,但我得到:
java.lang.ClassCastException: android.os.BinderProxy cannot be cast to com.octo.android.robospice.SpiceService$SpiceServiceBinder
at com.octo.android.robospice.SpiceManager$SpiceServiceConnection.onServiceConnected(SpiceManager.java:1072)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java)
at android.os.Handler.handleCallback(Handler.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:115)
at dalvik.system.NativeStart.main(Native Method)
服务流程看起来有点像这样:
class MyService extends Service {
// ...
SpiceManager mSpiceManager = new SpiceManager(UncachedSpiceService.class);
// ...
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
mSpiceManager.start(this);
mSpiceManager.execute(new MyRequest(), new RequestListener<String>() {
// Handle of request
})
// ...
return START_STICKY;
}
// + additional calls to mSpiceManager.execute() in other methods
}
这给了我服务启动后的类转换异常?