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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:54:39+00:00 2026-06-04T16:54:39+00:00

sorry about the cryptic question i am not sure how to word it. Intent

  • 0

sorry about the cryptic question i am not sure how to word it.

         Intent myIntent = new Intent(CurrentClass.this, ClassToCall.class);
         myIntent.putExtra("name", "value");
         Current.this.startActivity(myIntent);     

i know the above code can be used to pass a message from CurrentClass to ClassToCall but when i call the “finish()” method in ClassToCall i want to pass a String back to CurrentClass. can i get some help on how to do this ? once again sorry about how i’ve worded it.

  • 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-04T16:54:40+00:00Added an answer on June 4, 2026 at 4:54 pm

    Sometime we need to pass data or parameter to another Activity on Android. Only one activity is active at once. An activity open new activity for result and opened activity need parameter to set their interface or another option based on request. So it is important a system can handle sending and retrieve parameter between two Activity.

    Note: The startActivity(Intent) method is used to start a new activity, which will be placed at the top of the activity stack. It takes a single argument, an Intent, which describes the activity to be executed.

    It is really easy to use. You start and activity with a request code and you end it with a result code. The activity caller can then make use of the request code and the result code to implement a switcher and implement some logic. It is clear if you look at the following sample:

    startActivityForResult(intent, CREATE_REQUEST_CODE);
    

    In the same activity you need to implement the receiving method. It looks like this:

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
       if (requestCode == CREATE_REQUEST_CODE) {
          if (resultCode == RESULT_OK) {
            //ACT
          }
       }
    }
    

    Last part is in the activity being called. On the finish you have to specify the result code:

    setResult(RESULT_CANCELED, null);
    finish();
    

    //or

    setResult(RESULT_OK, null);
    finish();
    

    To conclude I advise you to reuse the result codes already implemented in android sdk. In particular you can reuse at least

    RESULT_CANCELED : Standard activity result : operation canceled.
    RESULT_FIRST_USER : Start of user-defined activity results.
    RESULT_OK : Standard activity result : operation succeeded. 
    

    Documentation from the developer.android.com

    Watch More information about this problem and examples:

    Link 1, Link 2 and may be best example(more).

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

Sidebar

Related Questions

Edit Question: Sorry about this basic question. This is a new technology to me.
sorry about the title, I'm not sure how to even describe this, which makes
Sorry about the length of this question. I'm new to Java and I've come
Sorry about the title, I'm not exactly sure how to explain this with a
I'm sorry about the title I'm just not sure how to describe this one.
I'm sorry about this question but I'm very new in mercurial, I have an
sorry about input mistakes, english its not my mother lang. I have this code
Sorry about this newbie question. Is there a way to execute multiple sentences at
Sorry about the vocabulary question but I can't find this anywhere: how do you
Sorry about the title — wasn’t sure how to word it. Basically I have

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.