views:

189

answers:

1

Hi

this is what I am trying to achive

1) My main application/activity starts a thread to listen to network messages (tcp). But I want this thread to listen to network messages (on tcp socket) as well as messages from main activity. I am exploring if I can use socket for network messages and Looper for internal messages. I dont think it will work as Looper is blocking.

In unix, we used Select to poll sockets to listen to messages on different sockets. Please advice how I can achieve Select like capability in Android?

Thanks! Manu

A: 

assumed you are listening to the network messages in a service you could youse intents to communicate between your activity and the service.

have a look at Intents and Intent Filters in the android documentation

flurin
Flurin:Thanks for your response!I am using a thread to handle network messages but I want this thread to get messages from main activity too.I believe Intents cannot be used to communicate between my main activity and the socket thread. Intents seem to be meant for communication between activities, services, broadcast.But your answer brings a new doubt: I can pass intents when starting an activity or a service. but once they are started, how do I communicate between them using intent. I do know know of any 'Intent listener' that can listen to incoming intents (except broadcast receivers)
Manu