글목록

2014. 4. 28.

[Android] Splash Screen Activity

1. MainActivity.Class 


package com.toplogic.splash;

import android.support.v7.app.ActionBarActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;



public class MainActivity extends ActionBarActivity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

    //SplashActivity start
        startActivity(new Intent(this, SplashActivity.class));

 }

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {

  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.main, menu);
  return true;
 }


}

2. SplashActivity.Class


package com.toplogic.splash;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.ActionBarActivity;

public class SplashActivity extends ActionBarActivity {
 
    @Override
     protected void onCreate(Bundle savedInstanceState) {
         
         super.onCreate(savedInstanceState);
         setContentView(R.layout.splash);
  
         Handler hdl = new Handler() {
             @Override
             public void handleMessage(Message msg) {
                 
                 finish(); // close splash
             }
  
         };
         hdl.sendEmptyMessageDelayed(0, 3000); // 3 second after finish
     }

}




3. splash.Xml










4. AndroidManifest.Xml



    

    
        
            
                

                
            
        
          
    







댓글 없음:

댓글 쓰기