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 6548983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:02:13+00:00 2026-05-25T12:02:13+00:00

I made an activity that increases a counter by one if the answer is

  • 0

I made an activity that increases a counter by one if the answer is correct, and decreases a counter by one if the answer is wrong. I have two different counters, and I modify them alternately.

So far everything works, but I would like to add to it so that if an answer is correct a new activity is opened. Here the user will decide whether the counter will be increased or not.

I have spent one day on it so far, but have not been successful.

  • 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-25T12:02:14+00:00Added an answer on May 25, 2026 at 12:02 pm

    Because you need only two counters, I will propose one very simple sollution, not “fancy” or “object oriented”, just simple and understandable.

    Use two static variables in the class of your main activity, let say:

    public static int player1Score, player2Score;
    

    Set them before starting other activities which need them:

    player1Score = player1Info.playerScore;
    player2Score = player2Info.playerScore;
    startActivityForResult(i, 1);
    

    Use them directly in your other activities. Write back their values in onActivityResult():

    player1Info.playerScore = player1Score;
    player2Info.playerScore = player2Score;
    

    Before writing them back you can also check if their values are changed:

    if ( player1Info.playerScore != player1Score )
        ...
    

    Thats all. Forget all complicated sentences like “observer design paradigm”, they can’t give you nothing here but lost time.

    Edit:

    If by some reason you don’t want to use static variables, you can subclass Application (android.app.Application) and declare normal variables there. Then in every activity you can get your application object through getApplication() and access your common variables there.

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

Sidebar

Related Questions

I have an activity made up of two fragments. On the left is a
My situation is following. I have one Activity that contains three main parts. At
I have made a shared preference activity that store the user settings, now i
I have an android app with links (made by linkify) that lead into other
I made a simple extension of CheckBoxPreference so that I could have my own
I have an activity that starts with an AsyncTask to check the connection to
I have a website that calculates a users involvement/activity using multiple MySQL queries. For
I have made one application for epaper/emagazine in which I want to give an
I have a activity that I want to rotate. I use the following in
I have a bug in my code that made me think I don't fully

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.