thread/timer
戻るボタンを押したら、アプリを停止して終了させたいです。timer.stop();
内部のタイマーonBackPressed()
が、使用したのと同じローカル変数であることをどのように伝え public void run()
ますか?
コード:
Thread timer = new Thread(){
public void run(){
try{
sleep(4400);
} catch (InterruptedException e){
e.printStackTrace();
}finally{
Intent openHome = new Intent(Splash.this, main.class);
startActivity(openHome);
finish();
}
}
};
timer.start();
}
public void onBackPressed(){
timer.stop();
}
これを入力すると、'timer' in timer.stop(); cannot be resolved.