以下代码来自https://github.com/android/camera/tree/master/CameraXBasic的CameraXBasic项目
我搜索了整个项目,但找不到PermissionsFragmentDirections
的声明。你能告诉我吗?
PermissionsFragment.kt
class PermissionsFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (!hasPermissions()) {
// Request camera-related permissions
requestPermissions(PERMISSIONS_REQUIRED, PERMISSIONS_REQUEST_CODE)
} else {
// If permissions have already been granted, proceed
Navigation.findNavController(requireActivity(), R.id.fragment_container).navigate(
PermissionsFragmentDirections.actionPermissionsToCamera())
}
}
private fun hasPermissions() = PERMISSIONS_REQUIRED.all {
ContextCompat.checkSelfPermission(
requireContext(), it) == PackageManager.PERMISSION_GRANTED
}
...
}