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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:32:43+00:00 2026-05-24T01:32:43+00:00

A.java public class A extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(A.class.getName(),

  • 0

A.java

public class A extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Log.d(A.class.getName(), "OnCreate");

        Intent intentB = new Intent(this, B.class);
        intentB.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        startActivity(intentB);
    }
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        Log.d(A.class.getName(), "onActivityResult");
    }
}

B.java

public class B extends Activity {

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Log.d(B.class.getName(), "OnCreate");

        Intent imagesIntent = new Intent(Intent.ACTION_GET_CONTENT);
        imagesIntent.setType("image/*");
        Intent openGalleryIntent = Intent.createChooser(imagesIntent, "pic");
        startActivityForResult(openGalleryIntent, 2);
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        Log.d(B.class.getName(), "onActivityResult");
        Log.d(B.class.getName(), data.getData().toString());
    }

}

AndroidMenifest.xml

<uses-sdk android:minSdkVersion="8" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".A"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="B"></activity>

    </application>

The problem is after selecting image from gallery, onActivityResult() method of class B class does not execute.

Though if intentB.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY) is removed from intentB instance then onActivityResult() of class B executes fine.

  • 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-24T01:32:44+00:00Added an answer on May 24, 2026 at 1:32 am

    This is the correct behavior. When you select FLAG_ACTIVITY_NO_HISTORY as the flag while calling the next activity. The child activity is removed from the stack and hence once you move out it would simply finish.

    Reference

    The question is why do you even want to use that flag?

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

Sidebar

Related Questions

//----AppActivity.java public class AppActivity extends Activity { Button Login; @Override public void onCreate(Bundle savedInstanceState)
i got 2 java files app.java and gallaery.java App.java public class App extends Activity
I have the following code in Main.java : public class Main extends Activity implements
findViewById returns null for EditText Java Code: public class MainActivity extends Activity { private
I have a simple code below: import java.util.ArrayList; public class BoidList extends ArrayList {
Here I found this code: import java.awt.*; import javax.swing.*; public class FunWithPanels extends JFrame
Consider the following Java class: public class Foo { public static void doStuff() {
in java we can do this: public class A{ public static void main(String...str){ B
I am following this tutorial: link text Preferences.java: public class Preferences extends PreferenceActivity{ @Override
My main class look like this: public class Soundboard extends Activity { SharedPreferences preferences;

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.