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

The Archive Base Latest Questions

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

In my application I have an Application and several Activities. I would like to

  • 0

In my application I have an “Application” and several Activities. I would like to kill my application after a specific time (ex. 3 minutes) after user pressed the Home button. I’m able to finish the “Application”s process but as long as my activities are alive, they tries to start from their last state.

Thread isOnDisplayThread = new Thread(new Runnable() {



            @Override
            public void run() {
                Timer mTimer = new Timer();

                mTimer.schedule(new TimerTask() {

                    @Override
                    public void run() {
                        Log.d(TAG, (isApplicationOnDisplay) ? "Application on display" : "APPLICATION ON BACKGROUND");

                        if (!isApplicationOnDisplay) {
                            notOnDisplayTime++;
                            if (notOnDisplayTime >= 10) {

                                Process.killProcess(Process.myPid());
                            }
                        } else {
                            notOnDisplayTime = 0;
                        }

                    }
                }, 0, 1000);

            }
        });

        isOnDisplayThread.run();

P.S. isApplicationOnDisplay is a static boolean controlled by every Activity’s onPause() and onResume() methods.

Is there any way to kill all related activities of an application?

  • 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-21T12:43:25+00:00Added an answer on May 21, 2026 at 12:43 pm

    (I can’t understand why everybody tries to kill his own application…)

    Killing an application should never be done by an application (though sometimes an task manager has his advantages).

    I’m able to finish the “Application”s process but as long as my activities are alive, they tries to start from their last state.

    You have full control about the state handling, you decide if an activity continue with the latest state or not. If you don’t want the current behavior, change it, but don’t try to kill your application.

    To make it short: The Android OS decides if an application should be killed/stopped or not

    Thats how android is designed and how it should be used…

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

Sidebar

Related Questions

I have an Android application composed by several Activities. Most of them need to
I'm working on an Android application that has several Activities. In it I have
In my application I have several activities, the main screen has 4 buttons that
In my application, I currently have several activities that consist of a TextView and
In my application I have several DataContexts that connects to different databases with different
So, you're writing a web application and you have several areas of the site
I have several web application projects in one solution. When I start debugging one
I have several RequiredFieldValidators in an ASP.NET 1.1 web application that are firing on
I have several properties that are dependent on the environment the application is running.
I have several deployment projects. In order to deploy an application, I need to

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.