I have implemented sample applicatioon with ListActivty.I have used CustomAdapter and i am getting some text of array from web service.I have shown those messages as list.when the data has changed from web serice that data not changing in my list.To get the updated message from service i have used broad cast reciever for recieve get the updation.In my broad cast reciever class i can able to get the lates messages by using Alaram manger.In this case i would like to update the UI without knowing user.
I have written code for get the messages to show intial vallues from web service as shown below:
usrMessages = new String[resultShoutMessage.size()];
userName = new String[resultShoutMessage.size()];
imgid = new Integer[resultShoutMessage.size()];
for(int i=0;i<resultShoutMessage.size();i++)
{
Log.v("ShoutGetMsgsScreen", "resultMessage*******>>>>"+resultShoutMessage.get(i).getShoutMessageText());
Log.v("ShoutGetMsgsScreen", "resultShoutNames*******>>>>"+resultShoutMessage.get(i).getShoutUserFirstName());
usrMessages[i] = resultShoutMessage.get(i).getShoutMessageText();
userName[i] = resultShoutMessage.get(i).getShoutUserFirstName();
imgid[i] = R.drawable.person;
}
In that case you can use
IntentService. Register aBroadCastReceiverthat will listen your when your data is downloaded from theWebServiceand get execute to update the UI. Pass your Intent toonHandleIntent()do the background process andsendBroadCastto Update your UI.Hereis an example for the same.