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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:27:18+00:00 2026-05-23T02:27:18+00:00

for quite some time i was blissfully of the opinion that static [instance] variables

  • 0

for quite some time i was blissfully of the opinion that static [instance] variables exist as long as the app runs. however, to my dismay, and much alarm, i feel that it’s not true.

for mere testing, i created a static list of strings, and in my main activity class overrode the onDestroy method to print a message to verify that the app exited. in the onCreate method i simply added a new string, and printed the contents of the list. what i’ve found is that the size of the list keeps on increasing, and all the string values added previously are still present.

i’ve read in places [even here on SO] that the instance variables exist as long as the app does, but i fear it’s not really so.

to be more precise, i came to be aware of this problem while using the Facebook SDK for Android. i’ve seen that the AuthListener instances within the list of listeners in the SessionEvents class just keeps on increasing over time. Hence, whenever the app is launched and the user logs in using FB, the listener methods get triggered as many times as there are instances present in the SessionEvents class.

Has someone observed this before, and is there some cardinal mistake i’m committing in understanding how android works?

what gives?

thanks for reading!

[UPDATE]
I stand corrected by BalusC and rdineiu. I really didn’t mean to create a confusion here about instance and class variables. Alas, in my haste to post my question i’ve committed a mistake i didn’t wish to. I am very well aware of the difference between static and instance variables. I just intended to write class variables, and can’t quite figure out what came over to refer to static variables as instance variables.

However, my question still stands.
@MisterSquonk – no, i’m not confusing here about when my Activity ends and when the app gets destroyed. Here’s what I tried on a sample – I’ve got only ONE Activity which serves as the Main. When I press the back button from this Activity, I’m assuming the Activity gets removed from the stack and the app also gets destroyed. I’ve launched the Task Manager to verify that my app is no longer running.

  • 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-23T02:27:19+00:00Added an answer on May 23, 2026 at 2:27 am

    so – i had posted the same question [unfortunately making the same mistake of terming static variables as instance variables] on the Android Developer Google group.

    I received some really good responses, especially from Kostya. My interactions on that group helped me to grasp the underlying “rules” of the Android platform.

    Hope the message thread helps you as well.

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

Sidebar

Related Questions

quite some time ago i noticed that in Visual C++ 10 ADL fails when
It's been quite some time now that I've been coding in C++ and I
I've been using MySQL for quite some time now. Most of that time I
After working on a page for quite some time, the customer now decided that
I've been using Ruby for quite some time now, however unlike PHP, as far
For quite some time I think that it is possible to add custom method
I was for quite some time under the impression that a for loop could
Having spent quite some time developping in C#, I noticed that if you declare
I spent quite some time researching for a library that allows me to compare
I had a bug that took me quite some time to fix. I kept

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.