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

  • Home
  • SEARCH
  • 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 8221063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:46:03+00:00 2026-06-07T13:46:03+00:00

I have the following Activity: public class StartActivity extends Activity { String str =

  • 0

I have the following Activity:

public class StartActivity extends Activity
{
    String str = "somestring";
    int number = "1";

    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // Code here
    }
}

I read the following on the Android docs (http://developer.android.com/reference/android/app/Activity.html)

If an activity is completely obscured by another activity, it is stopped. It still retains all state and member information, however, it is no longer visible to the user so its window is hidden and it will often be killed by the system when memory is needed elsewhere.

Does this mean that my class instances (str and number) are “alive” and available unless onDestroy is called or memory is needed after onPause or onStop is called?

  • 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-07T13:46:04+00:00Added an answer on June 7, 2026 at 1:46 pm

    If in your caller activity, you have called finish() method, then no instances of previous activity will be alive since you have finished caller activity. All the instances will be garbage collected.

    But if your caller activity, does not call finish(), then the activity will no longer be visible but, it will be present on the activity stack maintained by the operating system. The caller activity (i.e. the previous activity) may get finished in cases when the device is low in memory like in cases, ex.: if the activity calls Camera (which requires rich resources), in that case the previous activity may get destroyed.

    So in your case, the variables will be alive even if StartActivity is not the present visible activity.

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

Sidebar

Related Questions

I've got the following method... public class Image extends Activity { public void onCreate(Bundle
I have the following code: public class TestSynch extends Activity { public static ArrayList<HashMap<String,String>>
I have following code: public class readSensorsData extends Activity implements SensorListener { /** Called
I have the following Java code: public class FirstActivity extends Activity implements OnClickListener {
I have following function in one Activity public void AppExit() { Editor edit =
Within one Activity I have th following piece of code: public void onStartMonitoringToggleClicked(View v)
I have following code that displays an Image with letters, public class MainActivity extends
I have the following weird problem. My main activity looks like this: public class
I have the following asynctask class which is not inside the activity. In the
I have used following code for download some files from our internet. public class

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.