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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:36:51+00:00 2026-05-29T03:36:51+00:00

I’m working on an app that uses a custom class with other custom classes

  • 0

I’m working on an app that uses a custom class with other custom classes as members. ie:

public class TopClass {
    public OtherClass1 otherClass1;
    public OtherClass2 otherClass2;
}

This data needs to be available to several other Activities. I had been storing this in the main Activity of the app and was able to reference it.

Everything is working great except when running on a Droid X2. On that device it will run fine – until an external Intent is called. The same thing happens when switching to the Camera, Maps, or Calendar Intents: after returning to the app with either the back button or, in the case of camera, the “OK” button the app will FC with NPE referencing the “TopClass”

Here is an example of the camera call for reference:

public void startCamera(int pos) {
    Log.v(App.DEBUG_TAG, "startCamera(slot "+pos+")");

    Intent i = new Intent("android.media.action.IMAGE_CAPTURE");
    i.putExtra(MediaStore.EXTRA_OUTPUT, getFilesDir().getAbsolutePath());
    i.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivityForResult(i, pos);
}

I switched to using an Application class to store the “TopCLass”, but no change.

Using ACRA to get the stack traces and logcat where I’ve started logging every lifecycle event in the Activities I can see that the “TopClass” is null upon returning to the Activity. All of the local variables for the last Activity still exist in unchanged states, just the ‘global’ data has been nullified – GC’d, I am guessing.

I can’t duplicate this on my device (Droid Incredible running CM7 [2.3.7]), or any emulator – not even the X2 addon, nor on my wife’s Droid X.

I’m trying an experiment where I copy the ‘global’ “TopClass” to a local “TopClass” variable, but haven’t heard back on whether or not that has worked yet.

My questions are:

  1. What would be the proper or recommended way of persisting this data? From my reading I gathered that it was to use an Application class instance, but that isn’t working.

  2. Any ideas why the X2 is nulling out the Application-owned classes when calling an external Intent?

  • 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-29T03:36:52+00:00Added an answer on May 29, 2026 at 3:36 am

    What would be the proper or recommended way of persisting this data?

    You persist data in a file. Whether that is a database, SharedPreferences, or a file of your own design is up to you.

    Any ideas why the X2 is nulling out the Application-owned classes when calling an external Intent?

    Most likely, it is not “nulling out the Application-owned classes”. Rather, your process is being terminated. Any time you are not in the foreground, your process may be terminated to free up memory for other processes, whether you are not in the foreground because you launched a third-party activity, or the user pressed HOME, or the user brought up the recent tasks list and navigated to another task, or the user received a phone call, and so on. It is possible that the X2 is more aggressive about killing off background processes than are other devices, whether specifically by design or as a side-effect of other decisions made by Motorola.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build

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.