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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:06:20+00:00 2026-05-23T04:06:20+00:00

Hi there I am calling an startActivityForResult() and trying to process the result in

  • 0

Hi there I am calling an startActivityForResult() and trying to process the result in the onAcvityResult() method. However, the Intent data is null and result is RESULT_CANCELED. I am not sure why though.

I am creating activity with:

startActivityForResult(new Intent(this, Class.class),LIST_RESULT);

then in the Activity class

@Override
public void onBackPressed() {
    super.onBackPressed();

    Intent data = new Intent();
    Bundle bundle = new Bundle();

    bundle.putParcelable("name", la);
    data.putExtras(bundle);

    if (getParent() == null) {
        setResult(Activity.RESULT_OK, data);
    } else {
        getParent().setResult(Activity.RESULT_OK, data);
    }

    //finish();
}

finish() has no effect. In fact I get warning in LogCat that duplicate finish request HistoryRecord

And I am processing the result in:

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

    switch(requestCode) {
    case(LIST_RESULT):
        if(resultCode == Activity.RESULT_OK) {
            previousList = data.getExtras();
        }
    break;
    }

}

data is null and the resultCode is the Action.RESULT_CANCELED.

Any ideas why I am not getting any through? Is something changing it in between me setting it and reading it? The mParent is also null in the activity that returns result.

Alex

  • 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-23T04:06:21+00:00Added an answer on May 23, 2026 at 4:06 am

    Alex,

    I think you want to remove the called to finish() in your onBackPressed() method, and replace it with the call to super.onBackPressed(). I believe the call to super.onBackPressed() is calling finish and you are never getting a chance to call setResult().

    Try…

    @Override
    public void onBackPressed() {
    
        Intent data = new Intent();
        Bundle bundle = new Bundle();
    
        bundle.putParcelable("name", la);
        data.putExtras(bundle);
    
        if (getParent() == null) {
            setResult(Activity.RESULT_OK, data);
        } else {
            getParent().setResult(Activity.RESULT_OK, data);
        }
    
        super.onBackPressed();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way of calling a method/lines of code multiple times not using
The case: There is a .net application calling unmanaged C code. Used method for
I am trying to prevent my application calling the same method twice in the
I'm calling startActivityForResult() once on a menu item click, but the intent is being
Is there a way calling a Property Let method from inside the same class?
I am passing row id with the help of intent. The calling method being
Is there any reason for calling close methods on the StreamWriter class? Why do
Would there be any problems calling an HTTPS page (e.g. a credit card authorisation
Is there any difference between calling len([1,2,3]) or [1,2,3].__len__() ? If there is no
Is there any performance benefit/technical differences between calling EF SaveChanges() in a foreach loop

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.