2

I post EventBus.getDefault().post(new SendPlayer(player)); from a services, which is running in non main thread:

<service
  android:name=".player.PlayerService"
  android:process=":player"
  android:enabled="true"
  android:exported="true">
</service>

I expect to receive even in my fragment:

@Subscribe(threadMode = ThreadMode.MAIN) public void onEvent(SendPlayer event) {
  Log.w("mcheck", "onEvent");
}

However, I get message:
D/EventBus: No subscribers registered for event class yarh.com.tryexo.player.SendPlayer.

Events are delivered only if I remove android:process=":player".

Is it a bug or I misunderstood flow of posting events between background thread and main thread?

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
Yarh
  • 4,459
  • 5
  • 45
  • 95

1 Answers1

2

The process attribute causes your PlayerService to run in its own separate process pretty much like a totally different app.

This is like trying to fire an event in one app from another totally different app. You will need to find a different way to communicate with your service or place all components that need to communicate in the same process.

Kuffs
  • 35,581
  • 10
  • 79
  • 92