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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:28:29+00:00 2026-06-04T20:28:29+00:00

well most of us familiar with this pattern: public class MySingeltone { public String

  • 0

well most of us familiar with this pattern:

   public class MySingeltone {

    public String mSomeReferenceTypeData;
    public int mSomeValueTypeData;

    private static MySingeltone mInstance;

    private MySingeltone() {

    }

    public static MySingeltone getInstance() {
        if (mInstance == null) {
            mInstance = new MySingeltone();
        }

        return mInstance;
    }
 }

my problem is that I’ve found recently that the mInstance don’t equal null after activity using him been destroyed, or when the whole application suppose to be clause, for example:

public class SomeActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        MySingeltone mySingeltone = MySingeltone.getInstance();
        mySingeltone.mSomeReferenceTypeData = "some value";
    }
}

when launching “SomeActivity” next time after closing the whole applications running activities (say 10 seconds after..) the mInstance still holds the same reference, with the same values on his fields.

why does it happening?

what am I missing?

when android garbage collecting static members belongs to 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-06-04T20:28:31+00:00Added an answer on June 4, 2026 at 8:28 pm

    Since “mInstance” is a static variable it will not get null when you close your application. Closing of application doesn’t means that your application got destroyed.

    Also there is no concept of Closing your Android app. If you get out of your app it will not get destroyed at the same time. Android OS handles it internally when to close the app when it is no more in use. In case of memory shortage when android decides to destroy the app then this static variable will also got null.

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

Sidebar

Related Questions

Well, I'm learning Scala so this question may be too basic for most people.
As might be familiar to most of you, this is from Mark Pilgrim's book
I find that many high level functions are missing in most well-known javascript libraries
well i have most probably an extremly stupid problem but could not figure it
Well, StackOverFlow is such a good site, most of my google search results direct
Well, that might be a strange question, and maybe just because I'm not familiar
Seeing a checked expection in API is not rare, one of the most well
What is the most efficient way to do automatic form submission? I'm doing this
I have found a few threads in regards to this issue. Most people appear
This must be something very basic. I'm not familiar with the syntax, and this

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.