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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:17:14+00:00 2026-05-22T23:17:14+00:00

I have the following scenario (note that activity A has launchMode=singleTop ): Activity A

  • 0

I have the following scenario (note that activity A has launchMode="singleTop"):

  1. Activity A calls startActivityForResult() on activity B;
  2. Activity B calls startActivity() on C, after which setResult(RESULT_OK) and finish(); at this point, onActivityResult() in A is NOT called.
  3. Activity C calls startActivity() on A using FLAG_ACTIVITY_CLEAR_TOP and finish();

This is where my problem occurs. At this point, A‘s onActivityResult() is called with the right requestCode, but something else than RESULT_OK as the resultCode. I was expecting it to receive RESULT_OK because I have set it in B (which was started for result).

Why am I getting something other than RESULT_OK?

  • 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-22T23:17:14+00:00Added an answer on May 22, 2026 at 11:17 pm

    Read this doc:

    http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP

    If set, and the activity being launched
    is already running in the current
    task, then instead of launching a new
    instance of that activity, all of the
    other activities on top of it will be
    closed and this Intent will be
    delivered to the (now on top) old
    activity as a new Intent.

    Passing clear top flag will finish all activities in the stack. So what you’ll get in onActivityResult is probably a “notification” that the activity for which you want the result was canceled. (aka RESULT_CANCELED = 0x00)

    UPDATE

    When I use startActivityForResult, after setting the result, I always finish my activity and let the caller come to action.

    You are doing something less common: you set the result, finish your activity but you also start another one. I don’t know is the expected behavior in this situation. Can’t you change the interaction between the activities?

    You could try to call finish() first and then start the new activity (do this in activities B and C). Anyway, I also don’t know what should happen when you do this. I recommend you the first approach (changing the interaction so you don’t return a result and create a new activity at the same time).

    Perhaps you could chain two startActivityForResult or your activity B could send a new intent to A instead of returning its result?

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

Sidebar

Related Questions

Have the following scenario. I have a few form, which essentially have a few
I have the following scenario I have a main form as MDI parent and
Due to company constraints out of my control, I have the following scenario: A
I want to accomplish the following scenario in Drupal: You have 2 content-types. Lets
How could I best implement the following scenario? I have a Next Period... button
Hi I need some help with the following scenario in php. I have a
Let's assume we have the following generic scenario: An RDBMS as a data source,
I have the following scenario : SimpleDateFormat dateFormat = new SimpleDateFormat(dd/MM/yyyy); System.out.println(dateFormat.parse(31/05/2011)); gives an
I have the following scenario: I have 2 projects: Proj1 Proj2 Each of these
I was curious as to whether the following scenario is safe. I have the

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.