【发布时间】:2013-10-18 23:51:40
【问题描述】:
我开始在 splash.java 中添加声音,但我也遇到了错误
我得到的错误是:
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();
}
}
如果您能知道错误是什么以及如何解决它,我将非常感激。
【问题讨论】:
-
@JustinJasmann OP 正在传递
Context和Splash.this -
@justin 请贴出完整的logcat,你使用的代码是正确的。
-
@JustinJasmann 。对不起,我应该对我的程序做些什么修改?
-
我在尝试这个时实际上没有收到错误。