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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:45:18+00:00 2026-06-11T01:45:18+00:00

Alright, here I am again. Still learning. Now I need to pass integer values

  • 0

Alright, here I am again. Still learning. Now I need to pass integer values back and forth from 2 activities. First activity passes a counter value to the second (which keeps track of player stats). Second activity has ability to reset stats to zero, hence passing the number back. But I just can’t get my head around it. Here’s what I have so far…

First activity (Main):

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menu_settings:
            Intent i = new Intent(this, Options.class);
            Bundle counters = new Bundle();
            counters.putInt("plWin", plWin);
            counters.putInt("plLoss", plLoss);
            counters.putInt("plDraw", plDraw);
            i.putExtras(counters);
            startActivityForResult(i, ?);
            return true;

please fill in the “?”

second activity (Options):

public void onBackPressed() {
    super.onBackPressed();
    Intent i = new Intent();
    Bundle counters = new Bundle();
    counters.putInt("Wins", wins);
    counters.putInt("Losses", losses);
    counters.putInt("Draws", draws);
    i.putExtras(counters);
    setResult(?, i);
    finish();
}

again, can’t figure out the “?”.

And going back to my first activity, I don’t know what goes after:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

Dying to figure this out. Thanks in advance.

  • 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-06-11T01:45:19+00:00Added an answer on June 11, 2026 at 1:45 am

    Do like this

    startActivityForResult(i, 100);  
    

    For setResult

    setResult(RESULT_OK);
    

    You can use setresult for more advanced sending of results something like

    intent = new Intent();
    intent.putExtra("key", "I am done");
    setResult(1001, intent);
    

    And in onActivityResult

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {    
       if(requestCode == 100)
       {
        String key = data.getStringExtra("key");
        if(resultcode == 1001 && key!= null && key.equals("I am done"){
           //do something
        }else{
           //do something else
        }
    
       }
    } 
    

    You dont have to use setResult, if all you need to check is whether you returned from the activity then dont set it and dont check in onActivityResult

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

Sidebar

Related Questions

Alright, here I am again trying to write code from scratch and I can't
Alright so here it goes, I have my user system working perfectly, and now
Alright so here are my two tables. CREATE TABLE [cards] ( [id] TEXT PRIMARY
Alright so here is the question. I have a user class which contains a
Alright...I am here looking for some bread crumbs. This is my code: using System;
Alright, here goes. I'm making a very basic app, and I want the user
Alright, here is the output I get: arm-none-linux-gnueabi-ld --entry=main -dynamic-linker=/system/bin/linker -rpath-link=/home/oem/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib -L/home/oem/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib -nostdlib -lstdc++
Alright I'm totally baffled. Here's my code: if ($password == $correct_password[0] && !isset($_COOKIE['user'])) {
Alright I don't see why this isnt working. It seems pretty simple. Here is
Alright, so I'm making a Facebook-style chat. But that doesn't really matter. See here:

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.