I have one class with public int Result; Later in the game I use that variable to store number of points user makes. Now, I have another activity/class called Result and I have a textView in that activity and I need to use the Result variable to sexText to that textView. I made an instance of my game class and called it g in the Result class and than I did something like this:
score = (TextView) findViewById(R.id.tvResult);
score.setText("Game over!\nYour score is:\n" + k.Result);
But I always get 0. I think it's because I get default value of the variable, not the real one. How can I pass the final value added to my variable after game ends?
I also tried this in the game activity, to pass the variable as an intent:
Intent i = new Intent(Quiz.this, Result.class);
i.putExtra("newResultVariable", Result);
startActivity(i);
Also get 0.
Bundlewith Intent.putExtra()is fine.