Absolute beginner concerned with coupled classes

Put your problem here if it does not fit any of the other categories.

Absolute beginner concerned with coupled classes

Postby droidpt » Tue Dec 04, 2012 12:40 am


Although I have some experience in Java/Swing, I am an absolute beginner in Android.

One thing that concerns me is the way Intents work in Android as a way of activities to communicate. Although this mechanism is advertised as being able to loosely couple classes, it seems to me that it isn't quite that case.

For instance, if FirstActivity produces an event that should open SecondActivity, you have to explicitly mention SecondActivity.class.

As a Swing developer, I am used to completely decouple different screens (usually implements as JPanel sub classes) with events. If FirstScreen produces an event that should open SecondScreen, it broadcasts a custom event that is catched by a listener class implemented at a higher level on the container hierarchy of my app. That listener switches to the SecondScreen, acting as a mediator between FirstScreen and SecondScreen.
This way, none of those two screens know each other. Nonetheless, the application works as expected. Furthermore, if I either need to reuse my FirstScreen or replace SecondScreen for another equivalent screen, all I have to do is to modify my mediator listener.

What is the best approach to do this in Android? I already read about some custom frameworks such as EventBus and Otto that have a different approach to events and aim to "replace" the traditional Intent mechanism (or am I wrong)?
Once Poster
Once Poster
Posts: 1
Joined: Mon Dec 03, 2012 11:56 pm


Return to Other Coding-Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 15 guests