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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:38:02+00:00 2026-05-27T09:38:02+00:00

In my main activity, I have: Intent settings_intent = new Intent(this, SettingsActivity.class); settings_intent.putExtra(SomeID, some_int);

  • 0

In my main activity, I have:

    Intent settings_intent = new Intent(this, SettingsActivity.class);
    settings_intent.putExtra("SomeID", some_int);
    startActivityForResult(settings_intent, 1);

And then, in my SettingsActivity, I have:

@Override
public void onBackPressed() {
    super.onBackPressed();
    // pass back settings:
    Intent data = new Intent();
    data.putExtra("SomeThing", some_number);
    setResult(200, data);
    finish();
}

And finally, I overrode the following in my Main activity:

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

However, the “called” toast happens as soon as my “Settings” activity starts, instead of when it finishes. I’ve spent quite a while on this now. Any help is appreciated. 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-05-27T09:38:03+00:00Added an answer on May 27, 2026 at 9:38 am

    Most likely your settings activity has it’s launch mode set to singleTask in your manifest. This leads to a immediate cancel response when calling startActivityForResult().

    Note that this method should only be used with Intent protocols that
    are defined to return a result. In other protocols (such as
    ACTION_MAIN or ACTION_VIEW), you may not get the result when you
    expect. For example, if the activity you are launching uses the
    singleTask launch mode, it will not run in your task and thus you will
    immediately receive a cancel result.

    from the startActivityForResult() documentation

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

Sidebar

Related Questions

I have a main activity, then i call a new activity intent from this.
So I have this code in my main activity to start a new one:
I have 3 classes in my example: Class A, the main activity. Class A
I have a Activity called main. If I call Toast.makeText(this, Hello World from main,
I have a main activity which calls a child one via Intent I =
I have a widget that supposed to call an Activity of the main app
Say if I have a locationManager(LM) object in activity A, which is my main
I have an Android application with a main activity that is the tabhost. I'm
I have activity A in package one, and I want to run an intent
My application starts from an Main activity and this main activity has its own

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.