Oct 25, 2011

Android The Basics 8: Intro to Threads (finish splash Activity)




to Threads (finish splash Activity)

In this lesson you will:
-Finish our thread
-Get our splash screen up and running
-Learn about Threads the methods they can include
-Correct some mistakes
-Set up a new activity in the Android Manifest
-Set up the onCreate method for our myMenu class

This video is the 8th in a web series that I am creating to help you learn Android programming so you can create apps and eventually how to learn to write games for android phones. I want to explain things in a way that everyone can understand, even if you have no experience with Java, XML, C, OpenGL, or as a matter of fact, any other programming language.

If you do have a lot of experience with programming, these first videos will be really slow for you, but my goal is to get everyone sprinting, but for now we have learn to crawl.

Peace guys,

-Trav

HERE IS THE CODE FOR THIS TUTORIAL

main.java :

package com.mybringback.thebasics;

import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;



public class main extends Activity {

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle TravisIsAwesome) {

super.onCreate(TravisIsAwesome);

setContentView(R.layout.splash);

Thread logoTimer = new Thread(){

public void run(){

try{

sleep(5000);

Intent menuIntent = new Intent(“com.mybringback.thebasics.MENU”);

startActivity(menuIntent);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

finally{

finish();

}

}

};

logoTimer.start();

}

}

Android Manifest:




package=”com.mybringback.thebasics”

android:versionCode=”1″

android:versionName=”1.0″>










android:label=”@string/app_name”>












android:label=”@string/app_name”>















menu.java:

package com.mybringback.thebasics;

import android.app.Activity;

import android.os.Bundle;

public class menu extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

}

@Override

protected void onPause() {

// TODO Auto-generated method stub

super.onPause();

}

}

No comments:

Post a Comment