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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:01:10+00:00 2026-06-16T23:01:10+00:00

I am developing the application in which i want to close whole application on

  • 0

I am developing the application in which i want to close whole application on button click. I know in android we should not think about to close the application because android does that automatically from this Is quitting an application frowned upon?. but yet i want to close my application.

So what i am doing to close application is i am using Intent.FLAG_ACTIVITY_CLEAR_TOP flag to delete the activity stack.

Intent intent = new Intent(Activity3.this, FinishActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();

And in onCreate of FinishActivity.class i am calling this.finish() but application is not get closed and previous activity gets reopened.

FinishActivity.class

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    this.finish();
}

Update :

Here is the scenario

MainActivity->Activity2->Activity3->FinishActivity

Here Activity2 is gets opened after finishing the activity.

How do i achieve this? Any idea and suggestion will be appreciated.

Thanks & Regards

  • 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-16T23:01:11+00:00Added an answer on June 16, 2026 at 11:01 pm

    Use this–

     Intent intent = new Intent(Activity3.this, FinishActivity.class);
     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | 
     Intent.FLAG_ACTIVITY_NEW_TASK);
     intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
     startActivity(intent);
     finish();
    

    Edited–New Answer and would work perfectly..

    just taking an example…do it accordingly what your project needs–

    I am taking three Activity class A, B and C..and I have applied a close button on the view of class C Activity. If you want then by the Back button you can go to the previous Activity and when you press the close button then you would exit from apps..have a look–

    public class AActivity extends Activity {
    
      /** Called when the activity is first created. */
      @Override
       public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
        Intent i = new Intent(this, B.class);
        startActivityForResult(i, 1);
    }
    
    @Override
    protected void onActivityResult(final int requestCode,
            final int resultCode, final Intent intent) {
        super.onActivityResult(requestCode, resultCode, intent);
    
        if (resultCode == 5) {
            finish();
        }
    }
    }
    

    Take next class activity–

       public class B extends Activity {
        /** Called when the activity is first created. */
       @Override
      public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.b);
    
        Intent i = new Intent(this, C.class);
        startActivityForResult(i, 2);
    }
    
    @Override
    protected void onActivityResult(final int requestCode,
            final int resultCode, final Intent intent) {
        super.onActivityResult(requestCode, resultCode, intent);
    
        if (resultCode == 5) {
            setResult(5);
            finish();
        }
    }
    }
    

    Take last activity–

        public class C extends Activity {
       /** Called when the activity is first created. */
       @Override
       public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.c);
    }
    
        // close button..set by xml view..you can set it by button listener.
    public void close(View v) {
        setResult(5);
        finish();
    }
    }
    

    Hopefully, it would solve your problem..cheers!

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

Sidebar

Related Questions

I am developing an android application in which i want to use accelerometer. But
I am developing an android application in which I want to embed database in
I am developing android application in which i want to convert html code in
I am developing an android application in which I want to get UDID of
I am developing a bb application for which i want to center a button.
I developing an application in which i want to print the values on a
i am developing and application in which i want to get some feeds from
I am developing an application in which I want to record the sound of
I am developing an application in which I want to use push notification service.
I'm developing an application in which I want to check like to which power

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.