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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:47:31+00:00 2026-06-13T04:47:31+00:00

I have a Parent activity which is sending data to child activity but the

  • 0

I have a Parent activity which is sending data to child activity but the child is not returning the result. I posted portion of code from both activity altogether below- Theres a few code that I didnt post for unnecessity.

    public class TdeeActivity extends Activity {

    public static final int CALLED_ACTIVITY = 1;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tdee);
        Button ok=(Button)findViewById(R.id.btnOk);
        ok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View arg0) {
                Intent bmr= new Intent(TdeeActivity.this,BMRActivity.class);
                startActivityForResult(bmr,CALLED_ACTIVITY);
            }
        });
        }

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

        switch(requestCode) {
        case CALLED_ACTIVITY:
            if (resultCode == RESULT_OK) {

                Toast.makeText(this, "THE RESULT-"+data.getExtras().getString("result"),
                        Toast.LENGTH_SHORT).show();
            }
        }

    }
}  // end class

public class BMRActivity extends Activity{


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_bmr);
       Button btnOk=(Button)findViewById(R.id.btnOk);
       btnOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
                showResult();
            }
        });

        public void showResult() {


            Intent data= new Intent();
            data.putExtra("result",result);
            setResult(RESULT_OK, data);
            finish();



    }   



}




}// end class
  • 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-13T04:47:32+00:00Added an answer on June 13, 2026 at 4:47 am

    I tested you code in a dummy project and it was working fine at my end.. following is the code for both activity:

    public class ParentActivity extends Activity {
    
        private static final int CALLED_ACTIVITY = 0;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            Intent bmr = new Intent(ParentActivity.this, ChildActivity.class);
            startActivityForResult(bmr, CALLED_ACTIVITY);
        }
    
        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            super.onActivityResult(requestCode, resultCode, data);
    
            switch(requestCode) {
            case CALLED_ACTIVITY:
                if (resultCode == RESULT_OK) {
    
                    Toast.makeText(this, "THE RESULT-"+data.getExtras().getString("result"),
                            Toast.LENGTH_SHORT).show();
                }
            }
    
        }
    }
    
    
    public class ChildActivity extends Activity {
    
        final Activity activity = this;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            // Returning result from child activity
            Intent data = new Intent();
            data.putExtra("result", "from child"
                    + this.getCallingActivity().getClassName());
            setResult(RESULT_OK, data);
            finish();
        }
    }
    

    So please post more code so that issue can be found..

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

Sidebar

Related Questions

How I can get name of parent activity in child activity. I have two
I have an Activity which extends ExpandableListActivity and which contains some Parent Groups and
I’m new to android,I have an activity class which fetches Json string from url
I have an activity which extends ListActivity. It has many things but amongst them
So I have a fairly complex activity the parent being a linearlayout with a
I have parent/child relationship set up via Node Reference. A Child record can have
If you have Parent has_many :children Child Is there any reason a foreign key
I use Entity Framework 4 and I have parent - child relation with Cascade
I have a parent component, say P, which has function, say Pfunc. I also
I have a parent window and a few child windows attached to this. With

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.