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

  • Home
  • SEARCH
  • 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 7891285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:34:47+00:00 2026-06-03T06:34:47+00:00

I want to finish one activity from another activity, like: In Activity [A], on

  • 0

I want to finish one activity from another activity, like:

In Activity [A], on button click, I am calling Activity [B] without finishing Activity [A].

Now in Activity [B], there are two buttons, New and Modify. When the user clicks on modify then pop an activity [A] from the stack with all the options ticked..

But when the user click on New button from Activity [B], then I will have to finish Activity [A] from the stack and reload that Activity [A] again into the stack.

I am trying it, but I am not able to finish Activity [A] from the stack… How can I do it?

I am using the code as:

From Activity [A]:

Intent GotoB = new Intent(A.this,B.class);
startActivityForResult(GotoB,1);

Another method in same activity

public void onActivityResult(int requestCode, int resultCode, Intent intent) {

    if (requestCode == 1)
    {
        if (resultCode == 1) {
            Intent i = getIntent();
            overridePendingTransition(0, 0);
            i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            finish();

            overridePendingTransition(0, 0);
            startActivity(i);
        }
    }
}

And in Activity [B], on button click:

setResult(1);
finish();
  • 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-03T06:34:48+00:00Added an answer on June 3, 2026 at 6:34 am
    1. Make your activity A in manifest file: launchMode = "singleInstance"

    2. When the user clicks new, do FirstActivity.fa.finish(); and call the new Intent.

    3. When the user clicks modify, call the new Intent or simply finish activity B.

    FIRST WAY

    In your first activity, declare one Activity object like this,

    public static Activity fa;
    onCreate()
    {
        fa = this;
    }
    

    now use that object in another Activity to finish first-activity like this,

    onCreate()
    {
        FirstActivity.fa.finish();
    }
    

    SECOND WAY

    While calling your activity FirstActivity which you want to finish as soon as you move on,
    You can add flag while calling FirstActivity

    intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    

    But using this flag the activity will get finished evenif you want it not to. and sometime onBack if you want to show the FirstActivity you will have to call it using intent.

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

Sidebar

Related Questions

I want to finish the Activity on Home Button Click . I have below
I want to sent intent from one first activity to another. The first activity
I have a question regarding calling a method from one activity in a different
am trying to send a variable from one activity to another i have set
I have a program with several activities. One can start activity B from clicking
I am very confused in using finish() for activity and using back button of
I have two activities: one displays an image and a button, the other displays
I am developing one application. In that application I want to put Exit button.
I'm curious about one thing. How can I finish my current activity and start
So often, I want the user to select a start date and a finish

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.