【发布时间】:2013-07-25 19:42:24
【问题描述】:
美好的一天,我一直在为我的 android 程序做一些编码,我尝试在这里用这段代码播放音乐 android 最低版本是 2.2,最高版本是 4.2.2 也使用 eclipse 和设备模拟器是联结一号
地球上的这个
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();
}
}
有人可以帮我解决这个问题吗?
【问题讨论】: