I'm sorry for the title, I can't find a better way to describe my problem briefly. Here is my scenario. There are two apps, A and B. App A has one activity A1, and app B has three activities B1, B2 and B3.
Activity B1 is transparent and works as a proxy, I define intent filters for B1 so A1 can fire implicit intents to B1. Depending on intents' extras, B1 then will fire an explicit intent to start either B2 or B3, then finish itself. B2 and B3 don't have any intent filters and are supposed to be triggered by explicit intent from B1 only. The reason for B1/B2/B3 design is because
- I own app B, but not A so I can't change the way A fires intents
- I want to improve app B's UX with multiple activities instead of a single activity
Here is the 'proxy code' in activity B1
public void onStart() {
super.onStart();
// useB2() is some helper method that looks at intent's extra
// and decides if we should start B2 or B3
boolean useB2Activity = useB2(this.getIntent());
Intent intent = (Intent) getIntent().clone();
intent.setClass(this, useB2Activity ? B2.class : B3.class);
startActivity(intent);
finish();
}
Problem: If I go to app B the first time from app A, I can see B1's onStart() is called and then it starts B2 (for example). After that, whenever I go to app B from app A, B1's onStart() is NOT called, and B2's onResume() is called directly. For some reason, all subsequent intents fired from A1 does not go to B1. Instead it resumes B2 (or B3 depending on which one is created the first time when B1's onStart() is called). I don't know what's wrong here. Please help. Thanks.