I am developing one application which will send the request to server and get the response with data and then launch the homepage with the updated data.
I am using following approach:
- create handler in UI side and subscribe with the service.
- after subscribing with the service, send request to the server via service.
- service received the data and update the data in the registered handler.
Problem:
My observation is my homepage is getting launched with the default value so it seems like before getting subscribe with the service ,Ui is getting launched.
I want to restrict homepage display with default value, when response come from server with the data then only it should display with the updated data.
OR
it should display busy dialog until homepage gets updated with the received data, like how it behaves when we click on to get the weather/stock information on android phone.
So anyone could help with the appropriate approach? If someone can share with the example then it would be great for me.
Thanks,
Piks
Just go through the AsyncTask, its easy to implement Threading in android, also known as Painless Threading.
Let me explore more about AsyncTask. It provides 4 methods:
For example:
Now you can execute AsyncTask as: