Действие:
Код: Выделить всё
private ICallback callback = new ICallback.Stub() {
@Override
public void fire() throws RemoteException {
mTextView.setText("fired");
}
};
//then in onCreate i add:
mManger.registerCallback(callback);
Код: Выделить всё
interface ICallback {
void fire();
}
Код: Выделить всё
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");
}
}
Код: Выделить всё
public void registerCallback(ICallback callback) {
if (callback != null) {
mCallbacks.register(callback);
}
}
public void notifyCallbacks() {
final int N = mCallbacks.beginBroadcast();
for (int i=0;i
Подробнее здесь: [url]https://stackoverflow.com/questions/24429174/service-callback-throws-uncaught-remote-exception-exceptions-are-not-yet-supp[/url]