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

Reply via email to