I am making a IM client for android and i want to know how to do the communication between a Service and Activity.
I have a Service that establish the connection to gtalk, gets the contacts, listens for the incoming messages... , and i have the activity that is the UI of my application.
In the activity i create the service and bind the activity to it. I have an aidl interface to communicate between service and the activity with this methods:
String[] getContacts();
String[] getPressence();
int setConnection(int type);
void logOut();
So far so good, i can make the connection to gtalk, i can get the contacts and the status, but now i want to do a function in the activity that listens when the service gets a message and updates the UI...
For this i made another aidl file with the metod void receivedMessage(String message);
and whenever the service gets a message, i call that method, in the activity i display the message passed in the message String and i get an NullPointer exception.
Do i have to get the message in a handler or by some sync or async methods ? I am beginner in android and now i learn the services part so please help me .
Thank you very much!