제가 메인화면에서 게임뷰화면으로 넘어가고 싶은데 아래와 같은 코드를 작성하고 메인페스트에도 등록했는데 누르자마자 바로 앱이 종료됩니다.... 왜 그럴까요??
package com.example.dreamgame;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Timer;
import java.util.TimerTask;
public class MainActivity extends AppCompatActivity {
private MainActivity activity;
private GameView gameView;
private Handler handler = new Handler();
private final static long TIMER_INTERVAL = 30;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
gameView = new GameView(this);
setContentView(R.layout.activity_main);
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
handler.post(new Runnable() {
@Override
public void run() {
gameView.invalidate();
}
});
}
}, 0, TIMER_INTERVAL);
}
public void startBtnClicked(View v) {
Intent intent = new Intent(MainActivity.this, GameView.class);
startActivity(intent);
}
}