Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7705273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:49:48+00:00 2026-05-31T23:49:48+00:00

I have a problem with my activity. This is my onCreate: case NORMAL: game

  • 0

I have a problem with my activity. This is my onCreate:

case NORMAL:
        game = new Game(); // create new game
        game.initializeGame(); // initialize new game
        addSomeElements(result); // add elements to array due to user choice
        game.getCurrentLevel().nextPair(); // next pair of elements from array

        pictureGameLeft
                .setImageResource(colorsPictures.get(game.getCurrentLevel().getCurrentPair().getImageLeft()));
        pictureGameRight.setImageResource(colorsPictures.get(game.getCurrentLevel().getCurrentPair()
                .getImageRight()));


        break;
    case NOTNORMAL:
        game = new Game();
        game.initializeGame();
        addSomeElements(result);

        game.getCurrentLevel().nextPair();
        pictureGameLeft
                .setImageResource(shapesPictures.get(game.getCurrentLevel().getCurrentPair().getImageLeft()));
        pictureGameRight.setImageResource(shapesPictures.get(game.getCurrentLevel().getCurrentPair()
                .getImageRight()));

        break;

This is create new game due to user choice. When user choice NORMAL to arraylist “normal” will be add some elements. If user choice NOTNORMAL to arraylist “notnormal” will be add other elements. After that I get pair of elements from this arraylist and shows images.

Now this is my problem. When I choose any option, the game is create and shows two images. When I lock my phone and after that, unlock, I get other pictures. I think that my onCreate method is started again. I want to save first images and when I lock and unlock my phone I get the same pictures. How I can do this. I try use this solution after onCreate:

@Override
protected void onSaveInstanceState(Bundle savedInstanceState) {
    savedInstanceState.putIntegerArrayList("table", (ArrayList<Integer>) normal);
    super.onSaveInstanceState(savedInstanceState);

}

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    ArrayList<Integer> normal = savedInstanceState.getIntegerArrayList("table");

}

but it’s not working.

edit1:

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    ArrayList<Integer> normal = savedInstanceState.getIntegerArrayList("table");    
    pictureGameLeft.setImageResource(normal.get(game.getCurrentLevel().getCurrentPair().getImageLeft()));
        pictureGameRight.setImageResource(normal.get(game.getCurrentLevel().getCurrentPair().getImageRight()));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:49:49+00:00Added an answer on May 31, 2026 at 11:49 pm
     ArrayList<Integer> normal = savedInstanceState.getIntegerArrayList("table");
    

    after doing that you need to use those values too… I mean what ever you are doing in that switch case… do the same again

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like a simple problem: I have a WF4 activity that guides the
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I'm new to android and have been stuck on this problem for a long
I have the following problem: I have an Activity where a user can start
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I defined a new Activity on my project and I have some trouble with
I have looked through these forums to find a solution to this problem, and
I have a list activity, and I chose to manually add the first item
I have a problem with my game here. I kind of don't understand how
I'm developing an Android application and I have a problem running a new thread

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.