开发者

Android: Multiple singleTasks within a single Application: problem with <HOME>

I have 2 activities declared as singleTask in my application. The reason for t开发者_运维知识库his is, with standard mode, pressing "HOME" in one activity (say A) and launching another (say B), still shows activity A.

However, a new problem arises because of this.

A -> "HOME" -> B (Result : B, Expected Result: B) -> "BACK" -> (Result:A, Expected Result: Home Screen)

Any ideas why?


One thing that doesn't make sense:

pressing "HOME" in one activity (say A) and launching another (say B), still shows activity A.

However, a new problem arises because of this.

A -> "HOME" -> B (Result : B, Expected Result: B)

If pressing home in A and launching B still shows A is your goal with two singleTasks, then how can A -> HOME -> B have an expected result B for you?


Now I'll try and be helpful: Which Activity, A or B, handles the Launcher intent?

A -> HOME -> B (Result: B) would make me guess that B is that Activity that does, and if that is the case, your being at A before pressing HOME would mean that your stack would be something like A above B (A displayed), so pressing Home and launching B would make your stack B above A (B displayed).

Then if A and B are in a stack, pressing BACK will move you down from B to A (A now being displayed). This sounds like your problem.

If you want to take them to the home screen instead of moving down the stack, you will need to override the standard back button handler of the system, and whenever you need to override a system mechanic, it means you should double check what your doing is really the right way to achieve your goal.

If you post more information I will update my answer to help you sort this out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜