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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:55:07+00:00 2026-06-17T08:55:07+00:00

I have an application that accesses a server. I have many activities that access

  • 0

I have an application that accesses a server. I have many activities that access the server for data. At various points in the application, I do a simple check to verify two things, 1) There is internet connectivity and 2) The server is not in maintenance mode or down.. If it is, I display an Activity detailing why and when the server will be back up.

When a user clicks back in this “Server is down” Activity, I need to exit the application. I have tried the following code/intent to call the “Server Down” activity but it doesn’t work.

Intent i = new Intent(this, ServerMaintenanceActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);

I have looked all over and this is a very common problem faced with people typically on login/logout screens. None of the solutions I find works for me. I know it’s possible because I have apps that do just this for example Spotify.

Any ideas? 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-06-17T08:55:08+00:00Added an answer on June 17, 2026 at 8:55 am

    Whenever you start an activity, you can create new ResultReceiver then put it into a list, in a global helper class. Then, in your notification activity (telling the user “Server is down”), override onDestroy() and send request to finish others.

    For example:

    • Helper class:

      public static final int REQUEST_FINISH = 1;
      
      private static final List<ResultReceiver> mClients = new ArrayList<ResultReceiver>();
      
      public static void registerClient(ResultReceiver receiver) {
          mClients.add(receiver);
      }
      
      public static void unregisterClient(ResultReceiver receiver) {
          mClients.remove(receiver);
      }
      
      public static void finishApp() {
          for (ResultReceiver client : mClients)
              client.send(REQUEST_FINISH, null);
      }
      
    • Other activities:

      private ResultReceiver mCommandHandler;
      
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
      
          // ...
      
          mCommandHandler = new ResultReceiver(null) {
      
              @Override
              public void onReceiveResult(int resultCode, Bundle resultData) {
                  if (resultCode == Helper.REQUEST_FINISH) {
                      // do some other stuffs...
      
                      finish();
                  }
              }
          };
      
          Helper.registerClient(mCommandHandler);
      }// onCreate()
      
      @Override
      protected void onDestroy() {
          super.onDestroy();
          Helper.unregisterClient(mCommandHandler);
      }
      
    • Notification activity:

      @Override
      protected void onDestroy() {
          super.onDestroy();
          Helper.finishApp();
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that accesses a sql server 2008 database. The server and
I have a Python application in the bottle web-server that accesses a C shared-object
I have a web application that accesses Windows resources on another server. The code
I have VSTO application that needs to access a SQL server database but it
We have a windows application that runs on a server and accesses 4 other
I have a data-mining application that accesses a web-site to retrieve records on an
I have a SQL Server that holds a lot of data. An application, running
We have an legacy application that accesses the registry. Because it is a 32bit
I have an internal WPF client application that accesses a database. The application is
In my game application I have several different activities that all can be accessed

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.