我正试着在我的第一个简单的应用程序中开始简短的歌曲。一切都正常工作,直到我添加了"ourSong“对象,然后我在模拟器”不幸地MyApp停止了“上得到了错误,正如我说的,如果我评论"ourSong.start()"+ "ourSong.release()”,这个应用程序就能工作。
package com.example.helloworld;
import java.util.Timer;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
public class Splash extends Activity {
MediaPlayer ourSong;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
ourSong = MediaPlayer.create(Splash.this, R.raw.splashsound);
ourSong.start();
Thread timer = new Thread() {
public void run() {
try {
sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
Intent openStartingPoint = new Intent(
"com.example.helloworld.MAINACTIVITY");
startActivity(openStartingPoint);
}
}
};
timer.start();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
ourSong.release();
finish();
}
}

我很感谢你的帮助
发布于 2015-01-01 23:43:30
确保您的“原始”文件夹位于"res“中。
要了解更多细节,请看一下这。
在真正的设备上试一试!
https://stackoverflow.com/questions/27735536
复制相似问题