Huy Duong Tu
Huy Duong Tu

Reputation: 7928

Can't get onActivityResult when starting an activity from a child activity in TabActivity Android

In MainActivity.java, I extends TabActivity to use Tabhost.

public class MainActivity extends TabActivity 

In each Tab, I use ActivityGroup to manage some child activity

public class MerchandiserTabGroupActivity extends ActivityGroup

In a child activity A, I want to start another child activity B.

Intent intCreateClaim = new Intent(mContext, MultiPhotoSelectActivity.class);
startActivityForResult(intCreateClaim, Parameter.ACTIVITY_SELECT_IMAGE);

After I call setResult(RESULT_OK) and finish() in Activity B, onActivityResult() in Activity A isn't called.

Can anyone helps me? Thanks in advance.

Upvotes: 0

Views: 245

Answers (2)

Aux
Aux

Reputation: 438

This happens because after B activity finishes, Android returns to your TabActivity, not your A activity.

Use fragments. This way you will not have to deal with multiple activities. You will have only one parent activity with fragments inside. To make your life easier and to add support for pre-ICS Android devices, try GrilledUI library.

Upvotes: 1

Bradley Campbell
Bradley Campbell

Reputation: 9808

I know this isn't really the answer you're looking for, but you're using deprecated API. You should try a refactor and use the new Fragment API and the v4 support library if you need to support older versions of Android too. Using fragments you won't need to rely on setResult and onActivityResult.

Fragment

Fragment Tab Host

Upvotes: 2

Related Questions