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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:00:19+00:00 2026-06-05T03:00:19+00:00

Consider i am using five screen pages for project A.Each page is having switching

  • 0

Consider i am using five screen pages for project “A”.Each page is having switching between other pages sequentially one by one,my need is to do close all the page when i am clicking the button “exit” from the page five which is the last one.

I have used this below code,but the problem is only the last page is getting close others are not.

find my code below

Button extbtn = (Button)findViewById(R.id.but_Exit);
extbtn.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
Intent intent = new Intent();
    setResult(RESULT_OK, intent);
    finish();
}   });

Thanks for your time!

  • 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-05T03:00:21+00:00Added an answer on June 5, 2026 at 3:00 am

    Make all five activities extend a BaseActivity that registers a BroadcastReceiver at onCreate (and unregisters at onDestroy).
    When extbtn is clicked, send a broadcast to all those BaseActivities to close themselves

    for example, in your BaseActivity add:

    public static final String ACTION_KILL_COMMAND = "ACTION_KILL_COMMAND";
    public static final String ACTION_KILL_DATATYPE = "content://ACTION_KILL_DATATYPE";
    
    private KillReceiver mKillReceiver;
    
    @Override
    protected void onCreate(Bundle savedInstanceState)  {
        ...
        ...
        mKillReceiver = new KillReceiver();
        registerReceiver(mKillReceiver, IntentFilter.create(ACTION_KILL_COMMAND, ACTION_KILL_DATATYPE));        
    }
    
    @Override
    protected void onDestroy() {
        super.onDestroy();
        unregisterReceiver(mKillReceiver);
    }
    
    private final class KillReceiver extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            finish();
        }
    }
    

    and at extbtn’s onClick call:

    extbtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // send a broadcast that will finish activities at the bottom of the stack
            Intent killIntent = new Intent(BaseActivity.ACTION_KILL_COMMAND);
            killIntent.setType(BaseActivity.ACTION_KILL_DATATYPE);
            sendBroadcast(killIntent);
    
            Intent intent = new Intent();
            setResult(RESULT_OK, intent);
            finish();
        }
    });    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Effective Java , along with other sources suggest that we should consider using composition
I'd like to know situations in which I should consider using a framework other
I am currently working on a project. One library I would like to consider
If gathering requirements for a medium-to-large web-based project, at what point should one consider
This page suggests !ENTITY: If you want to avoid duplication, consider using XML entities
According to Javadoc, New implementations should consider using Iterator in preference to Enumeration If
I am wondering if there are any performance overhead issues to consider when using
Consider i am using join on three tables to get a desired result-set... Now
Consider: Dim line As String Using readFile As New StreamReader(SalesUpdateFile) While (line = readFile.ReadLine)
Consider the following code: using System; namespace ConsoleApplication2 { class Program { static void

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.