用导航组件拦截深链接
我正在使用应用程序中的导航组件,并且正在使用它来处理我的深层链接。它运行良好,但是就目前而言,它实际上只有登录我的用户的意图。这是因为我在假设用户已验证的模块中声明了深链路。身份验证是在另一个模块中完成的。
这是我的单个活动应用程序的导航图的粗略图。
NavHostFragment (app module, MyActivity)
|
|--- MyLoginFragment (login module, login_navigation.xml)
| |
| `---...
|
|--- MyHomeFragment (home module, home_navigation.xml)
| |
| `--- MyFinalFragment (my-app://deep-link/uri)
.
我在home_navigation.xml
homefragment
< fragment>
元素中设置了一个深链接。
我需要在活动
中拦截此深层链接,并在未登录用户时将它们路由回到登录模块。
是否有导航组件成语?还是我被迫在
并手动导航?on Create
中检查意图
myHomeFragment
/myActivity
I am using Navigation Component in my app, and I'm using it to handle my deep links. It's working great, but as it stands, it really only works as intended if my user is logged in. That's because I have the deep link declared in a module that assumes the user is authenticated. Authentication is done in another module.
Here is a rough diagram of my navigation graph for my single Activity app.
NavHostFragment (app module, MyActivity)
|
|--- MyLoginFragment (login module, login_navigation.xml)
| |
| `---...
|
|--- MyHomeFragment (home module, home_navigation.xml)
| |
| `--- MyFinalFragment (my-app://deep-link/uri)
.
I have a deep link set up in home_navigation.xml
inside the HomeFragment
<fragment>
element.
I need to intercept this deep link, possibly in the Activity
, and route them back to the login module when the user is not logged in.
Is there a Navigation Component idiom for this? Or am I forced to check the Intent
data in onCreate
of the MyHomeFragment
/MyActivity
and manually navigate?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论