Does the API demo for this work wherever you are running it? I have tested it on 3.0, 2.3, and 1.6, and it works in those places, not would I expect it to have any trouble elsewhere. (How this works is very simple, it just masks out the top X bits of the request code to determine which fragment to deliver the result to.)
Also of course if you are overriding FragmentActivity.onActivityResult(), you *do* need to be sure to call the inherited version. The behavior here is slightly different than the HC implementation; the activity method will always be called first. On Wed, Mar 9, 2011 at 8:14 AM, drasticp <drast...@gmail.com> wrote: > I have an application that targets 2.1. I'm using the Android > Compatibility Package to migrate the code in my Activities to > Fragments. I had an Activity which was launching a contact picker as > follows: > > Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, > Contacts.CONTENT_URI); > startActivityForResult(contactPickerIntent, CONTACT_PICKER_RESULT); > > The result was appropriately handled in the onActivityResult for the > Activity: > > @Override > public void onActivityResult(int requestCode, int resultCode, Intent > data) { > if (resultCode != Activity.RESULT_OK) return; > switch (requestCode) { > case CONTACT_PICKER_RESULT: > handleResult(data); > break; > } > } > > Now, I've migrated both the startActivityForResult call and the > onActivityResult into a Fragment. I have also extended > FragmentActivity in the hosting Activity. > > The contact picker still launches correctly, but onActivityResult in > the fragment is never called. If I override onActivityResult in the > FragmentActivity, it *IS* called. However, I don't want to handle the > result there because it breaks the encapsulation philosophy of the new > fragments. > > Shouldn't onActivityResult in the fragment be called? Am I missing > something? Thanks for your assistance! > > -- > 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+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en