简体   繁体   English

在设置中禁用位置信息权限时,Android App崩溃?

[英]Android App crashes when disabling the location permission from settings?

I am working on Xamarin Android Application. 我正在使用Xamarin Android应用程序。 I have asked a location permission from my app which if I enable from the app works properly. 我已经从我的应用程序中请求了位置许可,如果我从该应用程序中启用了该许可,则该许可可以正常运行。 But when i put the app in background and go to settings and disable the location permission and start the app again, the app crashes. 但是,当我将应用程序置于后台并转到设置并禁用位置权限并再次启动该应用程序时,该应用程序将崩溃。 What could be the possible solution to this problem? 这个问题可能有什么解决方案?

From Android M Android Required some permission at Run time like Location permission. 从Android M Android运行时需要一些权限,例如“位置”权限。 when you disable that permission from settings then when app running on background it not found that permission to access GPS in background.That's why app crash. 当您从设置中禁用该权限后,当应用在后台运行时,找不到后台访问GPS的权限。这就是应用崩溃的原因。 to avoid app crash show some message when permission declined and Handle Exception using try catch block. 为避免应用程序崩溃,当权限被拒绝时使用try catch块处理异常,并显示一些消息。

Read more about android Run time permission from here 此处阅读有关android运行时权限的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM