【发布时间】:2021-02-10 00:05:32
【问题描述】:
我目前正在尝试在 onResume() 方法中确定哪个片段是当前活动片段。
我目前基于目标 ID 进行检测。下载该应用的每个人的 ID 是否都相同,还是随机生成的数字?
我如何获得 ID:
Navigation.findNavController(getView()).getCurrentDestination().getId()
我是如何使用它的:
if (Navigation.findNavController(getView()).getCurrentDestination().getId() == 2131296382){
Log.w("Navigation", "The current fragment is the chat fragment");
}
【问题讨论】:
-
通过了解当前可见片段,您究竟想对信息做什么
标签: android android-fragments android-navigation android-jetpack-navigation android-navigation-graph