0

I'm making a dice game and I want to save the image View when I rotate the screen.

I have tried to save the value and then re-establish it. This worked but when I wanted to download the picture but the value I saved it does not work.

// How do I save this?

public void setDiceOne() {
    getDiceOne = new DiceAll(diceOne);
    getDiceOne.getRandomNumber();
    getDiceOne.getImageWhite();
}

public void setDiceTwo() {
    getDiceTwo = new DiceAll(diceTwo);
    getDiceTwo.getRandomNumber();
    getDiceTwo.getImageWhite();
}
Tobias Tengler
  • 6,848
  • 4
  • 20
  • 34
hajen78
  • 9
  • 2
  • Improve your explanation. – Taseer Jul 13 '19 at 11:06
  • I want to be able to save the values onSaveInstanceState and when the screen turns, everything is reset. so i want to resume my value from   if (savedInstanceState! = null) from the onCreate (Bundle savedInstanceState) method I don't know how to do it. I have been sitting with this for three days, I do not know if I have to do if the whole program takes too much time. – hajen78 Jul 13 '19 at 11:23
  • [This should help](https://stackoverflow.com/a/4101501/9968399). – Taseer Jul 13 '19 at 11:45
  • not really what I'm looking for. I do not want to send data to another activity. The data I want to save is in the same activity. I can kind of do that getDiceOne = new DiceAll (diceOne); oneVal = getDiceOne.getRandomNumber (); getDiceOne.getImageWhite (oneVal); here i can save the dice value and then submit it and get the image getDiceOne.getImageWhite (oneVal); i can save oneVal in onSaveInstanceState (Bundle outState) outState.putInt (VALONE, oneVal); and then resume from onCreate ()   if (savedInstanceState! = null) { oneVal = savedInstanceState.getInt (VALONE); – hajen78 Jul 13 '19 at 12:11
  • then my problem is how I pass it into      @Override      protected void onResume () {          super.onResume (); getDiceOne.getImageWhite (oneVal); } so this does not work. I don't really know what to do – hajen78 Jul 13 '19 at 12:12
  • I am having trouble understanding your problem correctly. Edit your question and include the code that you have tried. – Taseer Jul 13 '19 at 14:43
  • Thank you for taking the time to answer. I've solved the problem – hajen78 Jul 14 '19 at 01:21

0 Answers0