[英]Android development adding sound error
我開始在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();
}
}
如果您能知道錯誤是什么以及如何解決,我將非常感激。
問題在於,使用了錯誤的id
,因此應用程序對嘗試在此處使用哪個constructor
感到困惑。
MediaPlayer start = MediaPlayer.create(Splash.this, R.raw.splashsound);
不是正確的id
。 相反,它需要
MediaPlayer start = MediaPlayer.create(Splash.this, R.raw.e);
由於語法對於constructor
似乎是正確的(使用Context, reaourceid
),但是應用程序嘗試使用其他constructor
,因此,我使我認為resourceid
是錯誤的……以防萬一,它可以幫助任何遇到類似問題的人。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.