Android comes with the Apache HttpClient which has a number of methods
for handling async communication. I don't have a lot of experience
with that codebase but I suspect you will find some developers that
have used the HttpClient as an async manager.


Here is the architecture I have found works well.

1. Create a communication manager singleton to act as the source for
all your messages. That way all of your activities can access the
manager. When the app shuts down it will remove the singleton.

2. Within the singleton, I created a queue for messages and a
threadpool of HttpClient workers. You should do a search on
asynchronous message queues in java. There will be quite a few samples
for this.

3. The singleton has a call to send the message. Although not
necessary you can pass in a parser and a listener to process and
respond to the message respectively.

Here is an example of how the thread/messaging system can work.

http://code.google.com/p/apps-for-android/source/browse/trunk/Photostream/src/com/google/android/photostream/Flickr.java

I apologize for not being able to provide code but I don't have that
code available for public distribution.

Keep in mind Android is no different than other java based
asynchronous messaging. You should be able to find quite a few samples
of code based on that.






On Apr 13, 5:37 am, Pavol Kaiser <pavol.kai...@gmail.com> wrote:
> Hello,
>
> I want to create a communication layer in android. The layer will
> communicate with server asynchronously. Multiple activities should be
> able to call methods of the communication layer. The layer will get
> messages from the server (it is not important for the scope of this
> question how) and should be able to tell activities to do some work
> based on these messages.
>
> How should I implement this? Should I do this using android Service?
>
> The main questions that I need to answer are:
> How can activities access the layer?
> How can the layer access activities?
> How can i make the communication layer live for the lifetime of the
> application?
>
> Thank you for any help
> Palo

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to