【问题标题】:Android App crashes when disabling the location permission from settings?从设置中禁用位置权限时,Android App 崩溃?
【发布时间】:2017-09-13 08:54:47
【问题描述】:

我正在开发 Xamarin Android 应用程序。我已经从我的应用程序中询问了位置权限,如果我从应用程序启用该权限可以正常工作。 但是当我将应用程序置于后台并转到设置并禁用位置权限并再次启动应用程序时,应用程序崩溃了。有什么办法可以解决这个问题?

【问题讨论】:

  • 尝试在你的代码中捕获?
  • What could be the possible solution to this problem? 这取决于崩溃的原因。显示崩溃日志。
  • 弗拉德,一旦我从设置中撤销位置权限,应用程序就会重新启动,所以我无法查看日志。

标签: android permissions xamarin.android location runtime-permissions


【解决方案1】:

来自 Android M Android 在运行时需要一些权限,例如位置权限。当您从设置中禁用该权限时,当应用程序在后台运行时,它没有找到在后台访问 GPS 的权限。这就是应用程序崩溃的原因。为避免应用程序崩溃,在权限被拒绝时显示一些消息,并使用 try catch 块处理异常。

here阅读更多关于android运行时权限的信息

【讨论】:

  • Vinay,我有一个包含两个片段的活动,我在哪里显示消息?我在活动的 onResume 中实现了 checkselfpermission,以显示是否授予权限
  • 在禁用位置权限时检查应用程序崩溃的日志并添加 try-catch 块来处理异常。
  • Vinay,一旦我从设置中撤销位置权限,应用程序就会重新启动,所以我无法查看日志
猜你喜欢
  • 1970-01-01
  • 2022-11-28
  • 2018-06-05
  • 1970-01-01
  • 1970-01-01
  • 2019-12-23
  • 2016-04-24
  • 2018-09-02
  • 1970-01-01
相关资源
最近更新 更多