Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
android.app.Application NullPointerException
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
elubin  
View profile  
 More options Sep 23 2010, 10:03 am
From: elubin <elubin1...@gmail.com>
Date: Thu, 23 Sep 2010 07:03:55 -0700 (PDT)
Local: Thurs, Sep 23 2010 10:03 am
Subject: android.app.Application NullPointerException
When my app loads, I fill my android.app.Application with some data.
The app runs fine as I use it and all the data is available.

However, when I leave the app over night and look at it again the next
day, I receive NullPointerExceptions when attempting to use that same
data.  I do not believe Application objects get garbage collected, so
I have no idea what is going on?

I also lose static objects in classes used by my Activity classes.

I am on Froyo 2.2 on a Google Nexus One.

Looks like someone else had a similiar issue:
http://groups.google.com/group/android-developers/browse_thread/threa...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
TreKing  
View profile  
 More options Sep 23 2010, 12:59 pm
From: TreKing <treking...@gmail.com>
Date: Thu, 23 Sep 2010 11:59:27 -0500
Local: Thurs, Sep 23 2010 12:59 pm
Subject: Re: [android-developers] android.app.Application NullPointerException

On Thu, Sep 23, 2010 at 9:03 AM, elubin <elubin1...@gmail.com> wrote:
> However, when I leave the app over night and look at it again the next day,
> I receive NullPointerExceptions when attempting to use that same data.  I do
> not believe Application objects get garbage collected, so I have no idea
> what is going on?

> I also lose static objects in classes used by my Activity classes.

Hard to say without more details on how your app is structured, but it
sounds like your app is being killed and restored, but you're not reloading
/ resetting your data. Perhaps the path through which you do this loading /
initializing of variables is being skipped?

Logging all of the entry and exit points to your app you give you a better
idea of what's happening and when.

--------------------------------------------------------------------------- ----------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
elubin  
View profile  
 More options Sep 23 2010, 9:36 pm
From: elubin <elubin1...@gmail.com>
Date: Thu, 23 Sep 2010 18:36:38 -0700 (PDT)
Local: Thurs, Sep 23 2010 9:36 pm
Subject: Re: android.app.Application NullPointerException
That absolutely sounds like what is happening, but WHY would my app be
killed and restarted?  You are correct, if it gets restarted on the
main window then i am not refilling my application data.  I only fill
it on the login window.  Do I misunderstand how application data is
supposed to work?

I have a login window, the user enters id/pw, i log in through web
service, store some data in my application object, and leave the user
at my main application window.  i can then do any of my tasks, other
activities, etc.. using data from the application object.

when i click the icon and get back to the app the next day, it shows
me the main window again, right where i left it.  however, the
application object is empty?  what's the point of it if the JVM can
kill my app at any time and not store the application object?

help,
eric

On Sep 23, 12:59 pm, TreKing <treking...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Frank Weiss  
View profile  
 More options Sep 24 2010, 12:56 am
From: Frank Weiss <fewe...@gmail.com>
Date: Thu, 23 Sep 2010 21:56:02 -0700
Local: Fri, Sep 24 2010 12:56 am
Subject: Re: [android-developers] Re: android.app.Application NullPointerException

I think the lesson is that an Android application and
android.app.Application are frequently mistakenly assumed to behave the same
as an "application" on other operating systems.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
TreKing  
View profile  
 More options Sep 24 2010, 1:47 am
From: TreKing <treking...@gmail.com>
Date: Fri, 24 Sep 2010 00:47:06 -0500
Local: Fri, Sep 24 2010 1:47 am
Subject: Re: [android-developers] Re: android.app.Application NullPointerException

On Thu, Sep 23, 2010 at 8:36 PM, elubin <elubin1...@gmail.com> wrote:
> That absolutely sounds like what is happening, but WHY would my app be
> killed and restarted?

I'm guessing because it's idle long enough and Android feels like killing
it. If you're leaving your app alone over night, likely your phone is going
to sleep, pausing your app. Left in this state long enough, it's not
surprising that it would be killed eventually.

> You are correct, if it gets restarted on the main window then i am not
> refilling my application data.  I only fill it on the login window.  Do I
> misunderstand how application data is supposed to work?

Perhaps. As Dianne usually advises, you should scrap the Application idea
and use a lazy-loading Singleton object to store your global / app-wide /
static data as necessary.

>  what's the point of it if the JVM can kill my app at any time and not
> store the application object?

Well, I guess the point is to have the notion of an object that represents
your app as a whole. But it's not the system's job to store and restore it's
state - that's your job.

On Thu, Sep 23, 2010 at 11:56 PM, Frank Weiss <fewe...@gmail.com> wrote:
> I think the lesson is that an Android application and
> android.app.Application are frequently mistakenly assumed to behave the same
> as an "application" on other operating systems.

Yes, this is an important point. OP, you must remember that leaving your app
"open" does not mean it will never close as it does on Windows, for example.
Android will kill it and restart it as need be - it only *appears* to have
remained open since it restarts in the last activity you left it in.

--------------------------------------------------------------------------- ----------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
parag  
View profile  
 More options Sep 24 2010, 2:23 am
From: parag <parag.shetgaon...@gmail.com>
Date: Thu, 23 Sep 2010 23:23:47 -0700 (PDT)
Local: Fri, Sep 24 2010 2:23 am
Subject: Re: android.app.Application NullPointerException
 m not 100% sure but i feel this could help

http://developer.android.com/reference/android/app/Activity.html#onSa...)

but i feel if u can save the state of the objects
onSaveInstanceState(android.os.Bundle)
and restore them on onRestoreInstanceState(android.os.Bundle)

On Sep 24, 10:47 am, TreKing <treking...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »