Saturday, April 20, 2013

Threads in Android

Bagikan :
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

POSTING BERKAITAN




Template design by:
m-template | bagas96

0 comments:

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

Post a Comment