次のコードがあります。
package com.example.top_tech_deals;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.view.MotionEvent;
import android.widget.VideoView;
public class Splash extends Activity{
@Override
protected void onCreate(Bundle TravisLoveBacon) {
// TODO Auto-generated method stub
super.onCreate(TravisLoveBacon);
setContentView(R.layout.splash);
VideoView vv = (VideoView)this.findViewById(R.id.videoView);
String fileName = "android.resource://" + getPackageName() + "/" + R.raw.splashvid2;
vv.setVideoURI(Uri.parse(fileName));
vv.start();
Thread timer = new Thread(){
public void run(){
try{
sleep(12000);
} catch(InterruptedException e){
e.printStackTrace();
} finally{
Intent openStartingPoint = new Intent ("android.intent.action.MENU");
startActivity(openStartingPoint);
}
}
};
timer.start();
}
//Function that will handle the touch
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
synchronized(timer){
splashTread.notifyAll();
}
}
return true;
}
}
Bucky のチュートリアルの 1 つを使用して、12 秒間のスプラッシュ スクリーンを作成するために使用される上記のコードを作成することができました。また、ビデオが再生されるように変更しました。私が抱えている主な問題は、オンラインで見つけた OnTouchEvent であるコードの最後のビットにあります。すべきことは、ユーザーが画面をタップするだけでスプラッシュ画面をスキップできるようにすることです。これにより、ユーザーは MENU ファイルに移動する必要があります。
エラーは次の行にあるようです。
synchronized(timer){
「エラータイマーは変数に解決できません」と言っています
なぜこれが起こっているのですか、どうすれば修正できますか? 助けてくれてありがとう。