简体   繁体   English

导航组件隐式深层链接返回按下退出应用程序

[英]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.

相关问题 导航组件 - 后退按钮退出应用 - Navigation component - back button exits the app 导航组件隐式深层链接以空的 backstack 打开屏幕 - Navigation component implicit deep link opens the screen with an empty backstack 通过导航架构组件深度链接后的返回导航 - Back navigation after deep link by navigation architecture component 当通过导航组件的深层链接打开片段而不是返回到开始目标片段时,在返回按钮上关闭应用程序 - Close app on back button when fragment was opened by deep link of Navigation Component instead of returning to start destination fragment Android导航架构组件-系统的后退按钮退出应用 - Android navigation architecture component - system's back button exits the app 按主页,然后回到应用程序并按返回按钮,退出应用程序 - press home, then back to app and press back button,it exits the app Android Navigation Url Deep Link Back to Previous App - Android Navigation Url Deep Link Back to Previous App 当用户在导航组件中按下返回按钮时如何退出应用程序? - How to exit the app when the user press back button in navigation component? 如何在返回按钮按下时退出Android导航抽屉 - How to Android Navigation drawer exits on Back Button press 使用导航组件时按下后退按钮退出应用程序而不是导航到上一个屏幕 - Pressing back button exits the app instead of navigating to the previous screen while using navigation component
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM