我在查看有关远程Android服务的常见示例。但是,我在Logcat中一直收到以下错误信息:
10-22 19:50:33.947: E/AndroidRuntime(30624): FATAL EXCEPTION: main
10-22 19:50:33.947: E/AndroidRuntime(30624): java.lang.SecurityException: Binder invocation to an incorrect interface
10-22 19:50:33.947: E/AndroidRuntime(30624): at android.os.Parcel.readException(Parcel.java:1322)
10-22 19:50:33.947: E/AndroidRuntime(30624): at android.os.Parcel.readException(Parcel.java:1276)
10-22 19:50:33.947: E/AndroidRuntime(30624): at com.commonsware.android.advservice.client.IScript$Stub$Proxy.executeScript(IScript.java:82)
10-22 19:50:33.947: E/AndroidRuntime(30624): at com.commonsware.android.advservice.client.RemoteClientNewActivity$2.onClick(RemoteClientNewActivity.java:59)
10-22 19:50:33.947: E/AndroidRuntime(30624): at android.view.View.performClick(View.java:2532)
10-22 19:50:33.947: E/AndroidRuntime(30624): at android.view.View$PerformClick.run(View.java:9277)
10-22 19:50:33.947: E/AndroidRuntime(30624): at android.os.Handler.handleCallback(Handler.java:587)
10-22 19:50:33.947: E/AndroidRuntime(30624): at android.os.Handler.dispatchMessage(Handler.java:92)
10-22 19:50:33.947: E/AndroidRuntime(30624): at android.os.Looper.loop(Looper.java:143)
10-22 19:50:33.947: E/AndroidRuntime(30624): at android.app.ActivityThread.main(ActivityThread.java:4196)
10-22 19:50:33.947: E/AndroidRuntime(30624): at java.lang.reflect.Method.invokeNative(Native Method)
10-22 19:50:33.947: E/AndroidRuntime(30624): at java.lang.reflect.Method.invoke(Method.java:507)
10-22 19:50:33.947: E/AndroidRuntime(30624): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
我一直在尝试解决这个问题。
在这个活动中,我会这样做:
Intent i = new Intent("com.commonsware.android.advservice.IScript");
bindService(i,svcConn, Context.BIND_AUTO_CREATE);
并且。
public void onServiceConnected(ComponentName className,IBinder binder) {
service=IScript.Stub.asInterface(binder);
if(service !=null){
message = "connected";
}
}
请问有人能告诉我我做错了什么吗?