NavUtils当中navigateUpTo和shouldUpRecreateTask

博客介绍了Android中两个与Activity向上导航相关的方法。`navigateUpTo`用于从源Activity导航到指定Activity并结束源Activity;`shouldUpRecreateTask`判断导航时是否应重新创建任务栈,根据返回值可采用不同导航机制。
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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值