I'm trying to send my high score back to the main menu. Here are my intents. However, it just crashes when trying to get back to the main menu. My logcat is also below. Any tips would be great.
GameActivity
public void finish(){
Intent returnIntent = new Intent();
returnIntent.putExtra("GAME_SCORE",(gameView.getHitCount()));
setResult(RESULT_OK, returnIntent);
super.finish();
}
MainMenu
protected void onActivityResult(int requestCode, int resultCode, Intent retIntent) {
// Check which request we're responding to
if (requestCode == SCORE_REQUEST_CODE) {
// Make sure the request was successful
if (resultCode == RESULT_OK) {
if (retIntent.hasExtra("GAME_SCORE")) {
int scoreFromGame = retIntent.getExtras().getInt("GAME_SCORE");
tvhiScore.setText(Integer.toString(scoreFromGame));
}
}
}
LogCat
04-29 17:53:34.142: E/AndroidRuntime(1975): FATAL EXCEPTION: main
04-29 17:53:34.142: E/AndroidRuntime(1975): Process: cct.mad.lab, PID: 1975
04-29 17:53:34.142: E/AndroidRuntime(1975): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{cct.mad.lab/cct.mad.lab.MainMenu}: java.lang.NullPointerException
04-29 17:53:34.142: E/AndroidRuntime(1975): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
04-29 17:53:34.142: E/AndroidRuntime(1975): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)