我正在为 Samsung Watch 6 (WearOS) 开发一款基于 Sample Excercise 应用程序的应用程序。
我第一次安装它,它要求所有权限。然后我卸载了它并再次安装它,它没有要求任何权限。我什至重新启动手表,然后安装,它仍然不请求权限。
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// Bind to our service. Views will only update once we are connected to it.
ExerciseService.bindService(requireContext().applicationContext, serviceConnection)
bindViewsToService()
binding.startButton.setOnClickListener {
checkNotNull(serviceConnection.exerciseService) {
"Failed to achieve ExerciseService instance"
}.startExercise()
findNavController().navigate(R.id.exerciseFragment)
}
// Check permissions first.
Log.d(TAG, "Checking permissions")
permissionLauncher.launch(REQUIRED_PERMISSIONS)
}
发生什么事了?如果我转到“设置”>“应用程序”>“myApp”>“权限”,我会看到没有允许的权限。当我允许所有并启动应用程序时,它仍然显示
Missing Permission
。
我在
permissionLauncher.launch(REQUIRED_PERMISSIONS)
处放置了一个喙点,然后让它运行,我看到应用程序随后请求权限。所以我像这样添加了延迟
Handler(Looper.getMainLooper()).postDelayed(1000) {
permissionLauncher.launch(REQUIRED_PERMISSIONS)
}
应用程序现在正在请求权限。