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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:35:47+00:00 2026-05-24T08:35:47+00:00

I defined some global variables in my app by extending Application, as shown below.

  • 0

I defined some global variables in my app by extending Application, as shown below. When I leave the app, open more apps and play a bit with them, and go back to my app, the global variables have been deleted and my app crashes. I’ve got 2 questions:

1- How can this be possible?

2- How can I force my app to exit when going to background? I know I’m not supposed to do it, but I can’t find other solution…

Thanks

public class GlobalVars extends Application { 

    public static HashMap<Integer, String> ID2Cat = new HashMap<Integer, String>();

    // User logged bool
    public static boolean isLogged = false;

    // Current menu item
    public static int currentMenuItem = 0;
    public static boolean isHome = false;

    // Goodideas    
    public static JSONObject goodIdeas = new JSONObject();

    // Meteo
    public static JSONArray weatherItems = new JSONArray();

    // More stuff

}

Logcat

Here’s what makes me think my app is killed. This is shown at some point while playing with other apps.

I/ActivityManager( 2465): Process com.mysite.myapp (pid 23538) has died.
I/WindowManager( 2465): WIN DEATH: Window{4852a678 com.mysite.myapp/com.mysite.myapp.Home paused=false}
I/WindowManager( 2465): WIN DEATH: Window{485b63a8 com.mysite.myapp/com.mysite.myapp.Home paused=false}
I/WindowManager( 2465): WIN DEATH: Window{4826fbf8 com.mysite.myapp/com.mysite.myapp.ItemList paused=false}
I/WindowManager( 2465): WIN DEATH: Window{48286f90 com.mysite.myapp/com.mysite.myapp.ItemDetail paused=false}
W/GpsLocationProvider( 2465): Unneeded remove listener for uid 1000
D/GpsLocationProvider( 2465): stopNavigating
D/gps_BRCM( 2465): [status check] on_stop() : GPS_STATUS_SESSION_END
D/gps_BRCM( 2465): gps_engine_status_update 2
D/GpsLocationProvider( 2465): send an intent to notify that the GPS has been enabled or disabled
D/gps_BRCM( 2465): gps_stop: called
V/GpsLocationProvider( 2465): hybridGpsSensorDeregister : No registered sensorManager
D/GpsLocationProvider( 2465): hybridGpsSensorDeregister
  • 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-24T08:35:47+00:00Added an answer on May 24, 2026 at 8:35 am

    1- How can this be possible?

    Your process may be terminated at any point. You cannot assume how long any static data members or custom Application objects will live. They should only be used as a cache, at best.

    2- How can I force my app to exit when going to background?

    You don’t.

    I know I’m not supposed to do it

    Not only that, but it will not help you in this case. All it will do is mean that you crash 100% of the time, since you didn’t actually bother to initialize properly.

    but I can’t find other solution.

    Initialize your data. If your application is crashing because a new custom Application instance was created, your Application subclass has bugs, which you need to fix.

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

Sidebar

Related Questions

In my application I have to maintain some global application state and global application
We have an HTML page with some global JavaScript variables. We have some utility
I encountered a problem when declare some global variables using macros. Here is the
I am working on editing some old C++ code that uses global arrays defined
My aim is to retrieve some data from a global array which is defined
My aim is to retrieve some data from a global array which is defined
I am developing an application which has defined some intent filters (in the form
I've some classes defined in a dll file. These are in the form of
I have some logic, which defines and uses some user-defined types, like these: class
The curses.ascii module has some nice functions defined, that allow for example to recognize

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.