Reputation: 7214
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.
Upvotes: 0
Views: 1983
Reputation: 7214
onActivityResult()
in nested Activity
not call by Android.
The correct way to get activity result in nested activity is:
startActivityForResult()
from host Activity
(not from nested!),
receive Activity
result in host Activity
,
dispatch Activity
result to nested Activity
.
Upvotes: 2
Reputation: 3088
We had this https://groups.google.com/forum/?fromgroups=#!topic/android-developers/65oLmvIlgFM problem and solvedit by changing the activities launchMode to something other that singleInstace or singleTask.
Upvotes: 0
Reputation: 2629
If you want to call startActivityForResult()
from a Fragment you have to set the onActivityResult()
method in the Fragment class and not in the host Activity. See this link for more informations.
Upvotes: 0