I use EventBus (GreenRobot) to post from backgroundThread to my activity (which is a UiThread). I could start a fragment etc. I also want to update my Title, so I did as below. (calling the Activity setTitle())
@Subscribe
public void onEvent(AuthenticationEvent event) {
setTitle(event.getTitle());
}
However, there's an error as below reported. (The App didn't crash, but the Error is clearly shown on the log, and the Toolbar title behave weird after that).
E/EventBus: Could not dispatch event: class package.AuthenticationEvent to subscribing class class package.MainActivity
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:6357)
Is there a way I could workaround it, where the post from EventBus could still allow me to update my Ui (e.g. Title)?