开发者

Android app with second entry-point - switch to second entry-point when brought to front

I am writing an Android app with 开发者_StackOverflow社区two entry points that have intent filters defined so that both appear in the apps list and can be placed on the home screen and started from there (like Maps, Places, Latitude, etc that all start the Maps app in different activities).

The two entry points are "main" and "lists".

When the user selects the icon for the "lists" entry point from the home screen, the behavior I get at the moment is the following:

  • If the app is not running then it is started, and opened at the "lists" activity as desired

  • If the app is already running (but not in foreground) and was in a different activity from "lists", then the app is brought to the front at the current activity, not "lists".

I would like the homescreen "lists" shortcut to ALWAYS start the app at the "lists" activity, including the case when it is already running and brought to the front.

Is there anything in TaskAffinities, and LaunchModes that I could use to get the desired effect?

thanks


The easiest way to do this is to implement some code in onCreate() of all your Activities that checks the Intent that resumed the application and if it matches the lists intent then start that activity.

You could possibly mark it singleTop but in general I've found that it occasionally confuses things if you have many activities already in the stack or are dependent on specific stack ordering.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜