发布于 2014-08-29 12:25:19
不,这是不可能的,因为奥托,绿色机器人的EventBus,和LocalBroadcastManager都是过程中的解决方案.
您可以考虑从清单中删除android:process属性,因此它都在一个进程中运行。
发布于 2015-12-17 14:18:28
不,,但你可以使用中转。例如,使用BroadcastReceiver:在一个过程中,用数据发送一个broadcast,然后通过BroadcastReceiver onReceive方法内部发布一个otto事件。
就像我的密码:
public class ReceiveMessageBroadcastReceiver extends BroadcastReceiver {
public static final String ACTION_RECEIVE_MESSAGE
= "me.drakeet.xxxxxx.ACTION_RECEIVE_MESSAGE";
public static final String AGR_MESSAGE = "AGR_MESSAGE";
// this method can be called in other processes
public static void sendBroadcast(Context context, MessageContent content) {
Intent intent = new Intent();
intent.setAction(ACTION_RECEIVE_MESSAGE);
intent.putExtra(AGR_MESSAGE, content);
context.sendBroadcast(intent);
}
// this method will run in your default process, so you can post otto events to your
// default process
@Override public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(ACTION_RECEIVE_MESSAGE)) {
MessageContent content = intent.getParcelableExtra(AGR_MESSAGE);
Otto.getSeat().post(new PlayMessageReceivedEvent(content));
}
}
}发布于 2016-07-06 18:32:51
我知道这个问题有点老,但似乎有一个库声称它可以使用事件总线/Rx风格的架构处理跨进程通信。
https://github.com/edisonw/PennStation
免责声明:我没有试过这个,只是找到了,它声称做了这个问题所要求的。
https://stackoverflow.com/questions/25568181
复制相似问题