[英]Navigation Component implicit deep link back press exits the app
I've an implicit deep link created just like mentioned in the docs.我创建了一个隐式深层链接,就像文档中提到的那样。
https://developer.android.com/guide/navigation/navigation-deep-link#implicit https://developer.android.com/guide/navigation/navigation-deep-link#implicit
implicit - domain.com/ When I click on it, yhis opens a new instance of the activity, mentioned in the docs隐式 - domain.com/ 当我点击它时,yhis 打开一个新的活动实例,在文档中提到
If I press back it exits the app.如果我按回它退出应用程序。
The documentation says it should go back to the previous app and reloads that fragment, what am I doing wrong here?文档说它应该 go 回到以前的应用程序并重新加载该片段,我在这里做错了什么?
If the flag is not set, you remain on the task stack of the previous app where the implicit deep link was triggered. In this case, the Back button takes you back to the previous app, while the Up button starts your app's task on the hierarchical parent destination within your navigation graph.
What's the difference between back button and up button?后退按钮和向上按钮有什么区别?
The documentation says it should go back to the previous app and reloads that fragment, what am I doing wrong here?
文档说它应该 go 回到以前的应用程序并重新加载该片段,我在这里做错了什么?
The docs you've specifically quote says that the system back will take you back to the app that deep linked into your app, so the behavior you are seeing is expected.您特别引用的文档说系统返回将带您回到深入链接到您的应用程序的应用程序,因此您看到的行为是预期的。
For example, if you click a link in the Discord app and that app doesn't use FLAG_ACTIVITY_NEW_TASK
, then your app exists on Discord's task stack and are part of its back stack.例如,如果您单击 Discord 应用程序中的链接并且该应用程序不使用
FLAG_ACTIVITY_NEW_TASK
,那么您的应用程序将存在于 Discord 的任务堆栈中并且是其返回堆栈的一部分。 This means that the system back button is expected to take you back to Discord.这意味着系统后退按钮预计会将您带回到 Discord。
As per the Principles of Navigation , the Up button functions differently when your activity is placed on another app's task stack:根据Principles of Navigation ,当您的 Activity 被放置在另一个应用程序的任务堆栈上时,向上按钮的功能会有所不同:
The Up button never exists your app
向上按钮从不存在你的应用程序
When your app is launched using a deep link on another app's task, Up transitions users back to your app's task and through a simulated back stack and not to the app that triggered the deep link.
当您的应用程序使用另一个应用程序任务的 深层链接启动时,Up 会将用户转换回您应用程序的任务并通过模拟返回堆栈,而不是触发深层链接的应用程序。 The Back button, however, does take you back to the other app.
但是,后退按钮确实会将您带回到其他应用程序。
So it is expected that the Up button always keeps the user in your app and the Up button will never return the user to the Discord app.因此,预计向上按钮始终将用户留在您的应用程序中,并且向上按钮永远不会将用户返回到 Discord 应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.