如何检查我的应用程序是否始终或使用Xamarin.forms在Android中使用时获得权限
我正在使用Xamarin.Forms作为我的应用程序,并且正在使用Android设备。我想检查我的应用程序是否正在使用“始终”或“使用应用程序”在Android中的位置。
对于iOS,我可以使用 cllocationmanager.status 检查权限状态。
But in android I can't able to check the permission status of "Always" or "While Using the App"
CrossPermissions.Current.CheckPermissionStatusAsync(Permission.LocationWhenInUse);
通过使用上述条件,它始终返回“始终”或“使用应用程序时”。我想要确切的权限状态。 因此,任何人都请帮助我解决这个问题。
I am using xamarin.forms for my app and i am using Android device. I want to check whether my app is using "Always" or "While Using the App" for location in Android.
For iOS I can able to check the permission status using CLLocationManager.Status.
But in android I can't able to check the permission status of "Always" or "While Using the App"
CrossPermissions.Current.CheckPermissionStatusAsync(Permission.LocationWhenInUse);
By using the above condition it always return granted for both "Always" or "While Using the App". I want exact permission status.
So Anyone please help me to resolve this issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎没有API可以返回Android中位置许可的清晰状态。但是用户需要请求两个权限,
android.permission.access_fine_location
和android.permision.access_background_location
在Android中。此外,两个权限的不同结果意味着不同的位置权限状态:
android.permission.access_fine_location
deny
android.permission.access_background_location
,因此您可以执行运行时许可检查以获得清晰的位置许可状态。
It seems that there is no api which can return the clear status of the location permission in android. But the user need to request two permissions,
android.permission.ACCESS_FINE_LOCATION
andandroid.permission.ACCESS_BACKGROUND_LOCATION
in the android.Furthermore, the different result of the two permission means different location permission status:
android.permission.ACCESS_FINE_LOCATION
deny
android.permission.ACCESS_BACKGROUND_LOCATION
So you can do a runtime permission check to get a clear status of the location permission.