In my application for Android 2.2 + I will use ListView and communicate with the existing XmlRpc server. User will manually add items to the ListView and application will receive additional information about items from the xmlrpc server.
The application will do the following activities:
- test the connection to the xmlrpc server
- retrieve information from the server for manually added item to the
ListView - retrieve information from the server for all the items in a
ListView - send a list of items to the server
These activities I plan to implement as:
-
in
onCreate()I will useAsyncTaskto call xmlrpc function and then I will show OK/ERROR in status bar of application -
after pressing the ADD button I will use
AsyncTaskto call xmlrpc function to obtain information about the item (name, price, image) and then I will update the item just added. -
after pressing the GET ALL button I will use
AsyncTaskto call xmlrpc function to get information about all the items in the list (name, price, image) and then I will update all the items. -
after pressing the SEND button I will use
IntentServiceto call xmlrpc function and after I will display the result in the dialog box.
Is it appropriate to use AsyncTask and IntentService for my needs?
Thank you.
All internet communication shall happen in separate background thread, U NOT HOG UI THREAD, or your application will be killed by android OS. List views are not updated directly, but via their adapter which provides data and views for it. Assuming you have created and configured appropriate adapter, workflow will be as follows:
– rpc calls are processed in some background thread
– they update datastore in your adapter
– they signal via notifyDatasetChanged() ( from UI thread )
– list view asks adapter to provide views for all visible list items
– your interface is updated.
You do not neet to mess with intents when you stay inside same java process – standart multithreading will do.