I have run into the ClassCastException when using IBinder for android within a process. Following most of the online guides, inside of my service, I have
public class TestBinder extends Binder {
}
In my client,
private ServiceConnection testServiceConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
TestBinder mIBeaconBinder = (TestBinder)service;
.....
}
}
TestBinder mIBeaconBinder = (TestBinder)service; this throws the exception.
{
EDIT
public class TestBinder extends Binder {
public testService getService() {
// Return this instance of LocalService so clients can call public // methods
return testService.this;
}
}