09-21 17:13:18.934 3851-3851/alura.daniel.jumper E/AndroidRuntime: FATAL EXCEPTION: main
Process: alura.daniel.jumper, PID: 3851
java.lang.RuntimeException: Unable to resume activity {alura.daniel.jumper/alura.daniel.jumper.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void alura.daniel.jumper.engine.Game.inicia()' on a null object reference
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3121)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3152)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void alura.daniel.jumper.engine.Game.inicia()' on a null object reference
at alura.daniel.jumper.MainActivity.onResume(MainActivity.java:29)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1281)
at android.app.Activity.performResume(Activity.java:6320)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3110)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3152)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Esse é o erro que aparece no Android Monitor
Como resolver?
Os métodos inicia() e onResume() estão assim:
public void inicia() {
isRunning = true;
}
protected void onResume() {
super.onResume();
game.inicia();
new Thread(game).start();
}