Thursday, 17 September 2015

Splash Screen

Splash Screen

We accomplish this task by using Thread
The Thread will have a timer ad after sometime a new activity will come up, thus fullfilling our concept of splash screen

Set the content view in starting class as the splash screen.

 Thread timer= new Thread(){
  public void run(){
    try{
        sleep(3000);
       
    }
    catch(InterruptedException e)
    {
        e.printStackTrace();
        // or can do a log
    }
    finally{
            Intent openStartingPoint=new Intent("com.thenewboston.travis.STARTINGPOINT");// whatever the action name is or just the (fromclassname, toclassname)
            startActivity(openStartingPoint);
    }
  }
 };

 timer.start();

 // this makes the thing work but the problem is that if we hit the back button, it gors back to the splash screen
 // and then can take up some memory , so we should free up that



 so if we want to destroy the splashScreenActivity
 we should override the onPause() Method and call finish() inside it.



 Note- uri can be used to streamMusicFrom internet

  adding media to splsah screen
    MediaPlayer ourSong= MediaPlayer.create(context,ResourceID);// make oursong a class (instance variable)
    ourSong.start();
    One more thing to note is that  we dont want this song to keep playing in the next activity
    so ,
   
    in the onPause method we will release the oursong
    ourSong.release.

No comments:

Post a Comment