Skip to content

The service cannot receive eventbus events. #703

Open
@libq

Description

@libq

MyService.java

@Override
public void onCreate() {
    super.onCreate();
    EventBus.getDefault().register(this);
}
@Override
public void onDestroy() {
    super.onDestroy();
    EventBus.getDefault().unregister(this);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMyEvent(MyEvent event){
    Log.e(TAG,"onEvent");
}

MyFragment.java

EventBus.getDefault().post(new MyEvent());


manifast.xml

<application
    android:name="com.xxxx"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:usesCleartextTraffic="true"
    tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">
  <service android:name=".MyService" />

=======================================================
ps1: MyFragment send the event after MyService started.
ps2: EventBus version : 3.1.1
android minSdkVersion 14
android targetSdkVersion 28

Metadata

Metadata

Assignees

No one assigned

    Labels

    more info requiredNeeds more info to become actionable.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions