[英]Android Navigation Drawer: open deep fragment from notification
first sorry for my rusty English ! 首先,抱歉我的英语不好!
This is a doubt I have had for some time now and although my skills on Android have been getting better I haven't found an elegant solution for this issue: 这是我一段时间以来的一个疑问,尽管我在Android上的技能不断提高,但我还没有找到解决此问题的理想方法:
Lets say an application uses the Navigation Drawer pattern and has three levels of navigation: Home -> Posts -> Post details 假设某个应用程序使用了导航抽屉模式,并且具有三个导航级别:主页->帖子->帖子详细信息
When I open the App from the launcher I add the Home Fragment. 当我从启动器中打开应用程序时,将添加“家庭片段”。 From here the user can navigate all the way down to a given "post" using fragment transactions.
用户可以使用片段事务从此处一直导航到给定的“帖子”。
Now imagine there is some kind of notification that is letting me know something happened on a specific post: How would you create a "synthetic" back-stack when opening the app from the notification ? 现在想象一下,有某种通知让我知道特定帖子上发生了什么:从通知中打开应用程序时,如何创建“合成”后置堆栈? What I mean is:
我的意思是:
1- Open the app from the notification 1-从通知中打开应用
2- The app opens on Post Details 2-该应用程序在帖子详细信息上打开
3- Back navigation has to be > Posts > Home 3-返回导航必须是>帖子>主页
Thanks a lot in advance ! 在此先多谢!
without any line of code its hard to say how you are setting these Fragment
s , but you may need addToBackStack method or consider @Override
onBackPressed properly. 无代码它很难任何网上说你是如何设置这些
Fragment
S,但是你可能需要addToBackStack方法或考虑@Override
onBackPressed正常。 assuming notification is yours you can set id or whatever you need inside PendingIntent
extras Bundle
, obtain inside OnCreate
method and then create a stack 假设通知是您的,则可以在
PendingIntent
extras Bundle
设置id或所需的任何内容,在OnCreate
方法中获取然后创建一个堆栈
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.