I have to update different server data which takes huge time. I have to update the data on conditions. When I am running for loop, it’s stuck the device for a minute. I want to do through handler else any other option (which I can’t think). currently I am doing as:
for(int i=0;i>10;i++)
{
if(i==0)
handler.post(runable-1);//Different server data
if(i==1)
handler.post(runable-2);//different server data
if(i==2)
handler.post(runable-3);//different server data
...
}
How could I do? Also I have to show to user that which runnable is loading data…
Please help. Thanks
What you probably want is
AsyncTask. In your Activity class addAnd then, when you need to do the update:
Read up more on AsyncTask.
Also, note that your
forloop is not correct it should be<10and not>10. Finally, I suggest you useswitchcase instead ofif-else if-elseconstruct.