public static void navigateUpTo (Activity sourceActivity, Intent upIntent)
Navigate from sourceActivity to the activity specified by upIntent, finishing sourceActivity in the process. upIntent will have the flag FLAG_ACTIVITY_CLEAR_TOP set by this method, along with any others required for proper up navigation as outlined in the Android Design Guide.
This method should be used when performing up navigation from within the same task as the destination. If up navigation should cross tasks in some cases, see shouldUpRecreateTask(Activity, Intent).
Parameters
| sourceActivity | The current activity from which the user is attempting to navigate up |
|---|---|
| upIntent | An intent representing the target destination for up navigation |
public static boolean shouldUpRecreateTask (Activity sourceActivity, Intent targetIntent)
Returns true if sourceActivity should recreate the task when navigating 'up' by using targetIntent.
If this method returns false the app can trivially call navigateUpTo(Activity, Intent) using the same parameters to correctly perform up navigation. If this method returns false, the app should synthesize a new task stack by using TaskStackBuilder or another similar mechanism to perform up navigation.
Parameters
| sourceActivity | The current activity from which the user is attempting to navigate up |
|---|---|
| targetIntent | An intent representing the target destination for up navigation |
Returns
- true if navigating up should recreate a new task stack, false if the same task should be used for the destination
博客介绍了Android中两个与Activity向上导航相关的方法。`navigateUpTo`用于从源Activity导航到指定Activity并结束源Activity;`shouldUpRecreateTask`判断导航时是否应重新创建任务栈,根据返回值可采用不同导航机制。
5441

被折叠的 条评论
为什么被折叠?



