こんにちは、私は自分のAndroidプログラムでいくつかのコーディングを行っていました。ここでこのコードを使用して音楽を再生しようとしました。Androidの最低ビルドは2.2で、最高ビルドは4.2.2で、Eclipseを使用してこれを行い、デバイスエミュレーターはnexus 1です
これは地球上で
MediaPlayer Sound;
これはsetContentViewの下にあります
Sound = MediaPlayer.create(Splash.this, R.raw.kalimba);
Sound.start();
これがコード全体です
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
public class Splash extends Activity {
MediaPlayer Sound;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Sound = MediaPlayer.create(Splash.this, R.raw.kalimba);
Sound.start();
Thread timer = new Thread(){
public void run(){
try{
sleep(5000);
} catch(InterruptedException e){
e.printStackTrace();
}finally{
Intent openStartingPoints = new Intent("com.mysampleapp.simplybel.MainActivity");
startActivity(openStartingPoints);
}//this is the end for the finally
}//this is the end for the run
};//this is the end for the thread timer
timer.start();
}//this is the end for the oncreate
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
Sound.release();
finish();
}
}
誰でもこれで私を助けることができますか?