That does the trick also! Maybe it is a peculiar flow, but I don't find a better way to do it :(
The activity A needs the result from B before doing anything. I could launch B first and from there launch A passing the results, but B is an activity that can be invoked from multiple places and if I include the "where to go next" logic into it then it would be very difficult to reuse... don't you think? Thanks ;) Jose Luis. On Sun, Nov 9, 2008 at 8:47 PM, Romain Guy <[EMAIL PROTECTED]> wrote: > > You can do something very simple: when your Activity is killed to be > restarted, you will get a non-null Bundle instance in onCreate(). > Start B only when the Bundle is null. > > (I also find it weird that you start a sub-activity from onCreate(), > it is a rather peculiar flow.) > > On Sun, Nov 9, 2008 at 11:36 AM, qvark > <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > I have an activity A that the first thing it does is launching a > > subactivity B to get a result. So, in the onCreate() method of A, I > > have something like this: > > > > Intent intentB= new Intent(this, B.class); > > startActivityForResult(intentB, B_RC); > > > > This usually works fine, but if I change the orientation when I'm > > inside activity B, then when I close it activity A is recreated, so B > > is launched again. > > > > I tried modifying the invocation to B testing if a result has not been > > returned previously: > > > > if (!resultFromB) { > > Intent intentB= new Intent(this, B.class); > > startActivityForResult(intentB, B_RC); > > } > > > > protected void onActivityResult(int requestCode, int resultCode, > > Intent data) { > > if (requestCode == B_RC) > > resultFromB = true; > > } > > > > But it doesn't work because the activity A is created again BEFORE the > > onActivityResult method is called. > > > > I have seen something similar in the API demos (RedirectMain.java and > > RedirectGetter.java) and they solve it passing the result with a > > SharedPreferences object, instead of using the standard mechanisms. > > This seems to avoid the problem but I don't like it very much.... > > > > Any of you have found a better solution? > > > > Thanks, > > > > Jose Luis. > > > > > > > > > -- > Romain Guy > www.curious-creature.org > > > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---