0

I need to do a little in app chat for Android application. I'm using the aSmack lib, and I can get that working good. Here's my problem, I need to be able to switch to other bits of my app, but still receive and store new messages and get notified.

What is the best way to do this ?

I've had a look at the Service class but don't really get if it's what I need.

EDIT: also I can have more than one chat open at a time so when I'm talking to somone, messages to from the others must be saved too.

Thanks.

Sam
  • 341
  • 1
  • 4
  • 15
  • have a look at this link http://stackoverflow.com/questions/4769020/android-and-xmpp-currently-available-solutions/5487854#5487854 – Randroid Aug 02 '12 at 09:37
  • Thanks, but I already have a working solution, my problem is more a design problem. – Sam Aug 02 '12 at 11:23
  • I suggested looking at the source code of the Apps that use aSmack, to see how they are designed. – Flow Aug 02 '12 at 22:12
  • Finaly what I do and it seems to work is: public static HashMap> list_chat; I create this in the first Avtivity of my app, but I'm still not sure it's a good solution. – Sam Aug 04 '12 at 12:22

1 Answers1

0

Implement packet listener on service and store the messages in local database.After storing it in database send a broadcast message. Now you can receive it in any activity to show on UI.

Jaspreet Chhabra
  • 1,431
  • 15
  • 23