Wednesday, September 8, 2010

[android-developers] Re: calling finish() in onResume() a bad idea?

Ok, here are some reasons why you get null pointer exception

activity.finish() is an asynchrnous call..so you cant predict when
finish will be called.
Thinking that finish has been called before your next call to
startActivity will always result you a null pointer exception.

Thanks,

On Sep 8, 12:57 pm, TreKing <treking...@gmail.com> wrote:
> On Wed, Sep 8, 2010 at 2:44 PM, OldSkoolMark <m...@sublimeslime.com> wrote:
> > My use case is setting UI preferences (e.g. a different layout) in a
> > PreferenceActivity. When I return to the main activity's onResume(), I
> > check for preference changes and if a new layout is requested, I use
> > the code snippet above.
>
> I would call PreferenceActivity with startActivityForResult, then
> onActivityResult of the calling activity check if you need to "reset", then
> do what you're doing there instead.
>
> -------------------------------------------------------------------------------------------------
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices

--
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

No comments:

Post a Comment