classSplash

Last-modified: 2015-03-18 (水) 12:28:35
public class Splash extends Activity{

	MediaPlayer ouSong;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO 自動生成されたメソッド・スタブ
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splash);

		ouSong = MediaPlayer.create(Splash.this, R.raw.get_got);
		SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
		boolean music = getPrefs.getBoolean("checkbox", true);
		if(music == true){
			ouSong.start();
		}

		// timer
		Thread timer = new Thread(){
			public void run(){
				try {
					sleep(500);
				} catch (InterruptedException e){
					e.printStackTrace();
				} finally {
					Intent openStartingPoint = new Intent("com.example.startingpoint.MENU");
					startActivity(openStartingPoint);
				}
			}
		};
		timer.start();
	}

	@Override
	protected void onPause() {
		// TODO 自動生成されたメソッド・スタブ
		super.onPause();
		ouSong.release();
		finish();
	}
}




~
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/mini">
</LinearLayout>