I am creating an Instant Messenger for android using asmack.
I have started a Chat service which connects to xmpp server.
the service connects to xmpp server and i am getting the roster and presence.
but now i have to update the UI and pass the list of account objects from service to activity. i have come across Parcelable and serializable.
i can not figure out what is the correct way for this service.
Can some one provide some code samples where i can do the same.
Thanks
you’re making a nice app. I don’t know more about smack but I know how to pass objects from service to Activity. You can make AIDL for your service. AIDL’ll pass your service objects to activity. And then you can update your Activity UI. This link might be helpful to you!
First you have to make .aidl file using your editor and save this file on your desktop. AIDL is just like an interface nothing else. Like, ObjectFromService2Activity.aidl
Now copy this file and paste it to your project folder and the ADT plugin will generate the ObjectFromService2Activity interface and stub automatically in gen/ folder.
The Android SDK also includes a (command line) compiler aidl (in the tools/ directory) that you can use to generate the java code in case you don’t use Eclipse.
Override obBind() method in your service. Like, Service1.java
Start your service using your activity or where you want to start this service and make ServiceConnection. Like,
Using object of ObjectFromService2Activity you can access method s1.getObjectFromService() will return JSONObject. More Help Fun!