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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:01:23+00:00 2026-06-09T08:01:23+00:00

It may be a noob question but I have some doubt. I googled a

  • 0

It may be a noob question but I have some doubt. I googled a lot but found nothing.
In starting activity for result we pass request code and on result we check with the same request code and result code. I want to know Is there a way to Implement to perform different tasks and get different results from called activity by using request code i.e if the same activity is called many times with different request code then it returns different result. Please tell me how to do that. I found no way to have a switch statement or any other way to do this.

I already know the answers so editing this. I want to know If I can use the scenario like:

Intent intent = new Intent(this, yourClass.class); 
intent.putExtras(b);
if(condition1)
startActivityForResult(intent, 1);
else
startActivityForResult(intent, 2);

And my called Activity returns two differnt results for request code 1 and 2 , So I can have

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);

    //could replace it with a switch
    if (requestCode == 1){
        //condition 1
            }
        else if(requestCode == 2){
          //condition2
        }
}

i.e calling the same activity with different request code to get different results from the same activity.

Thanks

  • 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-09T08:01:25+00:00Added an answer on June 9, 2026 at 8:01 am

    The question posted was not so clear to me, You can always switch an activityForResult and check for activity result in onActivityResult method checking different request codes. Here is a code demonstration, how to do it:

    Switch activity using this:

    Intent intent = new Intent(this, yourClass.class); 
    intent.putExtras(b);    // here
    startActivityForResult(intent, 2); //put your code along : positive integer
    

    Check for result in this method

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        super.onActivityResult(requestCode, resultCode, data);
    
        //could replace it with a switch
        if (requestCode == 1){
            //put your code here
                }
    }
    

    The called activity does not need to know your requestcode, however, if you want to do something like that, you can do that by passing your request code in intent, like this:

    intent.putExtra("requestCode", requestCode); 
    

    Hence, access the intent variable in the activity class you switched onto..

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

Sidebar

Related Questions

This may sound like a noob question, because it is. I have tried for
It may be a noob question but is this something to do with my
May sound like a total noob question but i'm looking for a javascript (and
Ok this may seem like a bit of a noob question but one many
This may be a noob question but I want to hide the content within
this may sound like a strange question from a Python noob, but here's the
I know this may be a noob question, but it's bugging the heck out
This may be a noob question, but if I wanted to make a JSON
I may be asking a noob question here, but I can't seem to find
This is may be a noob question, but I was wondering why do we

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.