Использовать трансляции:
try {
msg.replyTo.send(Message.obtain(null, MSG_UPDATE_DATABASE));
} catch (RemoteException e) {
context.sendBroadcast(new Intent()
.setAction(Constants.ACTION_SERVICE_EXCEPTION)
.putExtra("msg", e.getMessage()));
}
А потом в вашей деятельности:
public class MyActivity extends Activity {
protected BroadcastReceiver mSyncReceiver = new BroadcastReceiver() {
@Override
public void onReceive(final Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(Constants.ACTION_SERVICE_EXCEPTION)) {
Toast.makeText(context, intent.getStringExtra("msg"), Toast.LENGTH_SHORT).show();
}
}
};
@Override
protected void onPause() {
super.onPause();
unregisterReceiver(mSyncReceiver);
}
@Override
protected void onResume() {
super.onResume();
registerReceiver(mSyncReceiver, new IntentFilter(Constants.ACTION_SERVICE_EXCEPTION));
}
}