0
我开始加入声音splash.java但IM得到一个错误,我也认为一切都很好,所以你可能会看到它,并帮助我与我会真的感激Android开发添加声音错误
错误即时得到的是:
Multiple markers at this line
- Syntax error on token ".", class expected after this token
- The method create(Context, Uri) in the type MediaPlayer is not applicable for the arguments (Splash,
上线
MediaPlayer start = MediaPlayer.create(Splash.this, R.raw.splashsound);
我的计划是:
package com.sc.uploader;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
public class Splash extends Activity {
@Override
protected void onCreate(Bundle IloveU) {
// TODO Auto-generated method stub
super.onCreate(IloveU);
setContentView(R.layout.splash);
MediaPlayer start = MediaPlayer.create(Splash.this, R.raw.splashsound);
start.start();
Thread timer = new Thread(){
public void run(){
try{
sleep(5000);
} catch (InterruptedException e){
e.printStackTrace();
}finally {
Intent openStarting = new Intent("com.sc.uploader.MAINACTIVITY");
startActivity(openStarting);
}
}
};
timer.start();
}
}
如果你能知道什么是错误以及如何解决这个问题,我将会非常棒。
你需要传递一个上下文:http://stackoverflow.com/questions/12154951/android-mediaplayer-create –
@JustinJasmann OP是通过'Splash.this'传递'Context' – codeMagic
@justin请发布完整的logcat,你使用的代码是正确的。 –