这是我的用例。我必须深入链接到具有与之关联的片段的活动。此深层链接要求我们登录应用。这是我的深层链接流
深层链接处理程序活动 ->(登录(->(首选项活动(。
如果您在登录后导航到加载主屏幕的目标活动,则导航路径将是
(主要活动( ->活动A -> (首选项活动(
登录活动调用目标活动,并调用finish()
从而从后退堆栈中删除自身。这是旧代码,无法更改。
我想做的是以下内容
在深度链接 -> 登录后加载目标活动后,如果用户第一次按下后退按钮,那么我想加载Activity A
然后在另一个后退按钮按下时Home Screen
。
有没有办法实现这一目标?我已经完成了以下教程
返回到安卓中后退堆栈中的不同活动
安卓活动后退堆栈(这是默认行为(。
我的意图在深层链接处理程序活动中启动活动。
Intent processorIntent = new Intent(this, PreferencesActivity.class);
processorIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
processorIntent.putExtra(PARAM_PREFERENCE, preference);
processorIntent.putExtra(PARAM_FLOW, true);
startActivity(processorIntent);
(Main Activity) - > Activity A -> (Destination Activity)
当用户第一次从Destination Activity
按下后退按钮时,您需要调用startActivity
,如下所示
@Override
public void onBackPressed() {
if(isFirstTime){
Intent intent=new Intent(this, A.class);
intent.putExtra(PARAM_FLOW, true);
startActivity(intent);
finish();
}else super.onBackPressed();
}
并在Activity A
中做同样的事情