I'm having some issues with my callbacks. Here is my code:
Activity:
private ICallback callback = new ICallback.Stub() {
@Override
public void fire() throws RemoteException {
mTextView.setText("fired");
}
};
//then in onCreate i add:
mManger.registerCallback(callback);
ICallback (AIDL)
interface ICallback {
void fire();
}
Manager:
public void registerCallback(ICallback callback) {
try {
mService.registerCallback(callback);
} catch (RemoteException e) {
Log.e(TAG, "Service is dead");
}
}
private void notifyCallbacks() {
try {
mService.notifyCallbacks();
} catch (RemoteException e) {
Log.e(TAG, "Service is dead");
}
}
Service:
public void registerCallback(ICallback callback) {
if (callback != null) {
mCallbacks.register(callback);
}
}
public void notifyCallbacks() {
final int N = mCallbacks.beginBroadcast();
for (int i=0;i<N;i++) {
try {
mCallbacks.getBroadcastItem(i).fire();
} catch (RemoteException e) {
}
}
mCallbacks.finishBroadcast();
}
My callbacks get notified but I run into this when it try to set the textview text:
E/JavaBinder﹕ * Uncaught remote exception! (Exceptions are not yet supported across processes.) android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.