Android Multiple Handlers Design Question

Posted by Soumya Simanta on Stack Overflow See other posts from Stack Overflow or by Soumya Simanta
Published on 2010-05-14T03:01:42Z Indexed on 2010/05/14 3:04 UTC
Read the original article Hit count: 357

Filed under:
|
|
|

This question is related to an existing question I asked. I though I'll ask a new question instead of replying back to the other question. Cannot "comment" on my previous question because of a word limit.

Marc wrote - I've more than one Handlers in an Activity." Why? If you do not want a complicated handleMessage() method, then use post() (on Handler or View) to break the logic up into individual Runnables. Multiple Handlers makes me nervous. I'm new to Android. Is having multiple handlers in a single activity a bad design ?

I'm new to Android. My question is - is having multiple handlers in a single activity a bad design ?

Here is the sketch of my current implementation.

I've a mapActivity that creates a data thread (a UDP socket that listens for data). My first handler is responsible for sending data from the data thread to the activity.

On the map I've a bunch of "dynamic" markers that are refreshed frequently. Some of these markers are video markers i.e., if the user clicks a video marker, I add a ViewView that extends a android.opengl.GLSurfaceView to my map activity and display video on this new vide. I use my second handler to send information about the marker that the user tapped on ItemizedOverlay onTap(int index) method.

The user can close the video view by tapping on the video view. I use my third handler for this.

I would appreciate if people can tell me what's wrong with this approach and suggest better ways to implement this.

Thanks.

© Stack Overflow or respective owner

Related posts about android

Related posts about design