Many of the network activities delay the program and the screen looks unresponsive. And ultimately you will get ANR.
You can overcome this with a thread
class MyThread extends Thread{
public MyThread(){
//initialise your variables
}
public void run(){
//write your expensive code here
}
};
In your ui therad you instantiate this thread
MyThread myt = new MyThread(a,b,c);
myt.start();
User will not notice the delay as myt is not in ui thread
You can overcome this with a thread
class MyThread extends Thread{
public MyThread(){
//initialise your variables
}
public void run(){
//write your expensive code here
}
};
In your ui therad you instantiate this thread
MyThread myt = new MyThread(a,b,c);
myt.start();
User will not notice the delay as myt is not in ui thread
Comments
Post a Comment