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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:17:29+00:00 2026-05-26T10:17:29+00:00

I want to close my application when it goes background. My current method is

  • 0

I want to close my application when it goes background.

My current method is to call finish() in the OnPause() of one of the main activity.

However, in my application there are several activities. When it jump to another activity from my main activity, my main activity will be closed.

It’s not what I excepted. I want my applications closed only when the entire applications goes to background (e.g. via Home key)

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-05-26T10:17:30+00:00Added an answer on May 26, 2026 at 10:17 am

    You can kill your own app’s process using Process.killProcess(Process.myPid()). If you can’t rely on a callback to you activity to tell you when your app has lost focus, and given that you can’t rely on onPause (as noted above), you could in principle post yourself a suicide note during onPause:

    _runnable = new Runnable() {
            @Override
            public void run() { 
                Process.killProcess(Process.myPid());
            };
    
    _handler = new Handler().postDelayed(_runnable, 3000);
    

    and then have one your other activities intercept and cancel it during onResume:

    _handler.removeCallbacks(_runnable);
    

    (You’ll need a way to provide access to the variables across multiple activities.) If the cancelation never comes, then your app will eventually be killed.

    Kludgy, but possible, I think.

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

Sidebar

Related Questions

The background: My form has a TWebBrowser. I want to close the form with
I want to close the front window of my application. How is that done?
I have an application, in that I want to close the entire browser on
I want check how to know user is using my application facebook Example: One
I want to close my application, so that it no longer runs in the
In my main activity, i call a dialog which is cancelable. I show this
I have an MFC application, which i don't want to be closed during the
I want to close a System.Windows.Forms.Form if the user clicks anywhere outside it. I've
I want to close a tab in my tab control when the mouse wheel
I want to close the dialog box when you click outside of the dialog,

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.