greenrobot-eventbus

EventBus comunication between activity and service

有些话、适合烂在心里 提交于 2021-02-19 08:30:06
问题 I'm working on an Android application with EventBus library. I have an activity and a service. I want to to fire an event from activity and receive it on service. The activity is: public class MainActivity extends AppCompatActivity { public static final String TAG="ACTIVITY"; @Subscribe(threadMode = ThreadMode.MAIN) public void onMessageEvent(StartEvent event) { Log.d(TAG, "Received message"); Snackbar.make(fab, "Stop task", Snackbar.LENGTH_LONG).show(); txtMessage.setText(event.message); };

Sticky events should remain after app close GreenRobot Eventbus

♀尐吖头ヾ 提交于 2021-02-19 03:38:06
问题 Using StickyEvents from GreenRobot - EventBus they don´t stay in memory after I close the app (showing the running apps and then slide to remove it from there) or after I run a new build from Android Studio . I mean onEventMainThread is not called after EventBus.getDefault().registerSticky(subscriber); Why? 回答1: EventBus is a runtime construct. Thus, sticky events only exist in memory during the lifecycle of a single run of an application. They can survive configuration changes and even

Trying to impact RecyclerView items via EventBus

狂风中的少年 提交于 2021-01-27 17:18:25
问题 I'm trying to post an EventBus event from an recycler item view class and subscribe to it in the same class so that the event is grabbed by ALL the recycler items. Now in more detail: I have a RecyclerView where each item (FriendListItem.kt) has a context menu. Only one context menu should be shown at a time. That means that I need to close another item's context menu if its visible. I chose to use the org.greenrobot.eventbus which we already widely used in our app. In the item class, when

How does fragment's lifecycle works inside viewpager? Why onStop is not called on navigation change?

被刻印的时光 ゝ 提交于 2020-04-16 05:42:38
问题 I'm using ViewPager 2 from AndroidX with 4 instances of the same fragment. My question is pretty straight forward. When I'm navigating to some another fragment(using navigation drawer or even something else). OnStop() , OnDestroy(), OnDettach() of the fragments inside the viewpager does not gets triggered. So why is that? And If I want to remove the listeners I've started already, in one of these methods, how can I do that? For example, I'm using GreenRobot's EventBus. And I'm registering the

How does fragment's lifecycle works inside viewpager? Why onStop is not called on navigation change?

只谈情不闲聊 提交于 2020-04-16 05:42:24
问题 I'm using ViewPager 2 from AndroidX with 4 instances of the same fragment. My question is pretty straight forward. When I'm navigating to some another fragment(using navigation drawer or even something else). OnStop() , OnDestroy(), OnDettach() of the fragments inside the viewpager does not gets triggered. So why is that? And If I want to remove the listeners I've started already, in one of these methods, how can I do that? For example, I'm using GreenRobot's EventBus. And I'm registering the

how to use greenrobot to pass data to activity or fragment that has not been initialized yet?

不羁的心 提交于 2020-01-12 14:04:34
问题 I tried to use greenrobot pass data between activities and fragment,but I couldn't find a suitable tutorial that show how do it in detail. Based on what I have read so far I wrote some thing like this,but it doesn't work.how can I use green robot to pass data to an activity or fragment that has not been inialized yet? MainActivity : @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); EventBus.getDefault().post(new String("We are the champions"));

Best practice for eventbus with thread safety

拜拜、爱过 提交于 2020-01-01 06:11:31
问题 My app has activities for the user interaction and a background service which is the only place where the data model is being modified. The background service listens to actions that where made by the user as well as incoming messages from the network. Therefore concurrency issues can arise which I try to prevent by using a handler. For the event layer I use greenrobots Eventbus. This is all working well but I wonder if there is a smarter/faster/less code extensive (and therefore less error

Unexpected behavior of same methods in different threads

走远了吗. 提交于 2019-12-25 16:55:08
问题 My initial question was: Android GraphView project get freeze with real time updates. In this one I was asking about possible concurrency in UI thread of 3 plots. On memory allocation plot it looks like this: I was receiving data directly from my ProcessThread in main activity and pass it using onEventMainThread from EventBus library back to the GraphFragment . All the data that is passed comes from ProcessThread which gathers data from Bluetooth listening service and then proceeds it to get

EventBus, register and registerSticky method

懵懂的女人 提交于 2019-12-22 01:45:56
问题 I use greenrobot EventBus library to send data between two fragments in my android app and I want to know what is the diffeence between register(Object b) method and registerSticky(Object object) method? 回答1: EventBus allows you to post events that are "sticky" and by that EventBus understands events that "stick to the eventbus" for future access. If you post a normal event when there are no subscribers registered at the moment of sending, this event will be discarded. You can post a sticky

IPC in Android using GreenRobot eventbus

假如想象 提交于 2019-12-19 01:18:24
问题 I need to communicate with a remote service, using (greenrobot) EventBus. Unfortunately, it does not seem to work with IPC. Looking at the code, I don't see a workaround either. Any help would be appreciated ! Bonus question - are there any other EventBuses (for Android) which support IPC ? 回答1: I need to communicate with a remote service, using (greenrobot) EventBus. The entire point of greenrobot's EventBus, like Square's Otto and LocalBroadcastManager , is to not use IPC. Any help would be