Search code examples
androidandroid-activityandroid-fragmentsandroid-tabhost

onActivityResult() is never call in nested Activity


I have the next UI hierarhy:

FragmentActivity -> Fragment with TabHost and LocalActivityManager -> MyNestedActivity

MyNestedActivity places in single tab in Fragment. When I call startActivityForResult() in MyNestedActivity, Activity starts normally, but onActivityResult() in never called.

But if I open MyNestedActivity using startActivity(), onActivityResult() works fine.

When I must hook onActivityResult()? In FragmentActivity on in Fragment? How I must dispatch result to my MyNestedActivity?

SOLVED:

In this UI hierarhy onActivityResult() not called. I just change MyNestedActivity to Fragment and my hierarchy become FragmentActivity -> Fragment. Now onActivityResult() works fine.


Solution

  • onActivityResult() in nested Activity not call by Android.

    The correct way to get activity result in nested activity is:

    1. startActivityForResult() from host Activity (not from nested!),

    2. receive Activity result in host Activity,

    3. dispatch Activity result to nested Activity.