Friday, August 9, 2013

How to create a thread in Android Development

I figured it's been a while since making a post on Android development, so today I will provide an example of a thread. A thread is a way that multiple activities can occur simultaneously in Android while using memory in an efficient way. In an Android app, it is standard to have an intro screen begin before being passed to a home activity or menu. Below is an example.

Thread myTimer = new Thread() {

public void run() {

try {

int timer =0 ;
while(time<5000) {


timer = timer + 100;
sleep(100);

}

startActivity(new Intent("com.activityname.clear"));
} catch(Exception e) {

e.printstacktrace();

}


}



};

myTimer.start();

Don't forget to try out my new app for movies, music and books

No comments:

Post a Comment