is unknown to this NavController (使用navigation.fragment回退是的处理;)
回退方法:
NavHostFragment.findNavController(this).navigateUp()
findNavController().popBackStack()
在使用这个findNavController().popBackStack()方法从FragmentA返回FragmentB的时候 ,然后在进入FragmentA就会包 那个错误;
然后使用NavHostFragment.findNavController(this).navigateUp() 这个方法函数从FragmentA返回FragmentB的时候 ,然后在进入FragmentA就不会报错
看了navigateUp()的函数的注解 如下:
/** * Attempts to navigate up in the navigation hierarchy. Suitable for when the * user presses the "Up" button marked with a left (or start)-facing arrow in the upper left * (or starting) corner of the app UI. * * <p>The intended behavior of Up differs from {@link #popBackStack() Back} when the user * did not reach the current destination from the application's own task. e.g. if the user * is viewing a document or link in the current app in an activity hosted on another app's * task where the user clicked the link. In this case the current activity (determined by the * context used to create this NavController) will be {@link Activity#finish() finished} and * the user will be taken to an appropriate destination in this app on its own task.</p> * * @return true if navigation was successful, false otherwise */
下面是对上面的翻译:
/ ** *尝试在导航层次结构中向上导航。 *当用户按下应用程序用户界面*(或开始)左上角的向左(或开始)箭头标记的“向上”按钮时适用。 * *
当用户*没有从应用程序自己的任务到达当前目的地时,Up的预期行为不同于{@link #popBackStack()Back}。例如如果用户*在另一个应用的*任务上托管的活动中正在查看当前应用中的文档或链接,而用户单击该链接。在这种情况下,当前活动(由用于创建此NavController的*上下文确定)将{@link Activity#finish()完成},并且*用户将根据自己的任务被带到该应用程序中的适当目的地。< / p> * * @return如果导航成功,则返回true,否则返回false * /
popBackStack()函数注解 如下
/** * Attempts to pop the controller's back stack. Analogous to when the user presses * the system {@link android.view.KeyEvent#KEYCODE_BACK Back} button when the associated * navigation host has focus. * * @return true if the stack was popped and the user has been navigated to another * destination, false otherwise */
下面是对上面的翻译:
/ ** *尝试弹出控制器的后堆栈。类似于当用户*关联的导航主机具有焦点时按下系统的{@link android.view.KeyEvent#KEYCODE_BACK返回}按钮。 * * @return如果弹出堆栈且用户已导航到另一个目标,则返回true,否则返回false /
这个链接 里面有30多个回答,用来解决这个错误的途径;访问起来有点慢,引文是国外的
然后把文件下载到了本地