1

I develop some apps for android and always come to point where I need to communicate within

  • Fragment to Activity
  • Activity to Fragment
  • Fragment to Fragment
  • Service to Fragment
  • etc.

At the Android documentation they recommend to use interfaces to communicate between Activity and Fragment for example. But I have for example 4 Fragments, then my Activity needs to implement 4 Interfaces. I my intention right?

So I tried Otto and it is worth to try it. However I recognized, if you don't track the bus events you could get very confused.

I searching for a strategy to avoid those approches. How does it Google or other major developer?

loose11
  • 607
  • 6
  • 31
  • Otto and EventBus libraries are common by start-up companies and it makes develop faster. These communication statemens are really confusing when trying to implement it with interfaces. Most of classes are having pointers of listeners. You can keep going with it. On the other hand, services are already have binding features to communicate with classes. Fragments are having arguments which you can pass data with bundle class. Intent for activities and etc. Personally, i do it with Otto. – Emre Aktürk Dec 17 '14 at 17:56
  • How do you keep track of all your Producer, Consumer etc? – loose11 Dec 18 '14 at 08:40
  • I create a package which is named "Event" and adding all the neccesary classes in it and all classes have Event suffix. – Emre Aktürk Dec 20 '14 at 13:03
  • Ok, thats also my way to keep track of the events. But I think, it is difficult to say, which class trigger another class through the bus :/ – loose11 Dec 21 '14 at 12:40
  • I use Ctrl+Alt+F7 (Usage in Project) to see other classes. – Emre Aktürk Dec 22 '14 at 12:20

1 Answers1

5

If you are using IntelliJ or Android Studio for development you can minify confusion with Otto IntelliJ Plugin.

colriot
  • 1,978
  • 1
  • 14
  • 21