Monday, July 25, 2011

[android-developers] Re: Curious NPE

On Jul 24, 2:20 am, Zsolt Vasvari <zvasv...@gmail.com> wrote:
> Is onBackPressed called from a different thread perhaps? I wouldn't
> have thought so, but stranger things have happened.   And if that's
> the case, how can I ensure that my variable is initialized.  I cannot
> construct it on the decleration as the object depends on the intent
> passed in to the Activity.

I imagine that all of the method an activity or view can override
would be performed on the UI thread, otherwise chaos would ensue.
Especially anything dealing with keypresses, which would normally go
on the UI thread anyway.

> My Activity can take a couple of seconds to display,  and if I press
> the back button quickly one of two things happen on my Nexus One: it
> either doesn't register at all or that the activity flickers on and
> off and I am back to the original Activity.  In no case did it crash
> in my testing.
>
> But as I said, I got some other errors like this for a member that
> should have been initialized in onResume.

Do you know which device? Maybe it's running something that was
highly modified by the manufacturer and they happened to break a case
that Google's compatibility tests don't check for. Maybe they have a
slower device that makes it easy to register a back button press
before onCreate is called.

Maybe you could dive into Android's source for Activity for some
clues. Or maybe you could just check for null and be done with
it. :-)

Doug

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate