I am facing an error while binding the service with interface stub().
Here is my Connection code:
class LogConnection implements ServiceConnection {
public void onServiceConnected(ComponentName className,
IBinder boundService) {
logService = ILogService.Stub.asInterface((IBinder) boundService);
}
but its not working for me.
Logcat:
06-22 12:17:28.632: I/dalvikvm(1973): Could not find method com.sam.logservice.ILogService$Stub.asInterface, referenced from method com.sam.logclient.LogClientActivity$LogConnection.onServiceConnected
06-22 12:17:28.662: W/dalvikvm(1973): VFY: unable to resolve static method 28: Lcom/sam/logservice/ILogService$Stub;.asInterface (Landroid/os/IBinder;)Lcom/sam/logservice/ILogService;
06-22 12:17:28.662: D/dalvikvm(1973): VFY: replacing opcode 0x71 at 0x0009
06-22 12:17:28.662: D/dalvikvm(1973): VFY: dead code 0x000c-0016 in Lcom/sam/logclient/LogClientActivity$LogConnection;.onServiceConnected (Landroid/content/ComponentName;Landroid/os/IBinder;)V
06-22 12:17:28.702: W/ActivityManager(61): Unable to start service Intent { cmp=com.sam.logclient/com.sam.logservice.ILogService }: not found
EDIT:
I am following the example of below link :
When I did Debugging the code at that time I struck at the same
position
logService = ILogService.Stub.asInterface((IBinder) boundService);
Hope you have some solution.
Please let me know if you want more data to conclude on reason.
In your code I observed thats why are you casting boundService it to IBinder there is actually no need to cast it just pass it as it is.
So, your line should look like this
make sure the service written in same package ..
The class where your extending service just create object of interface
and in onBind method return it as shown below
Hope this explanation works for you .