如何调试/重置Android 6.0权限? [英] How to debug/reset Android 6.0 permissions?

本文介绍了如何调试/重置Android 6.0权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在迁移我的一个应用程序以使用Android 6.0权限系统时,我发现使用模拟器调试权限非常困难.

While migrating one of my apps to use the Android 6.0 permissions system, I found it very hard to debug permissions using the emulator.

发现:

  • 在使用requestPermissions()方法时,在应用程序信息屏幕中禁用权限不会重新显示授予权限"对话框.
  • 重新安装应用程序似乎是使应用程序再次显示授予权限对话框的唯一方法.
  • Disabling a permission in the app info screen doesn't re-show the grant permission dialog when using the requestPermissions() method.
  • Reinstalling the app seems to be the only way to make the app show the grant permission dialog again.

使用Android模拟器调试权限的正确方法是什么?

What is the proper method to debug permission using the Android emulator?

推荐答案

调试Android 6.0权限实际上非常容易.您可以使用以下ADB shell命令将当前前景应用程序的权限重置为安装状态" 所有应用程序:

It’s actually very easy to debug Android 6.0 permissions. You can reset the permissions to the "install state" for the current foreground app all apps using the following ADB shell command:

adb shell pm reset-permissions

注意::程序包管理器(pm)工具帮助部分指出:当前您无法重置特定程序包的运行时权限:

Note: Currently you can't reset the runtime permissions for a specific package, the package manger (pm) tool help section states:

将所有运行时权限还原为默认状态.

revert all runtime permissions to their default state.

您可以使用Android Studio中的终端界面轻松执行reset-permissions命令.请注意,只有在将ADB目录添加到PATH系统环境变量的情况下,ADB命令才有效(请参阅:

You can easily execute the reset-permissions command using the terminal interface in Android Studio. Note that ADB commands only works if the ADB directory is added to the PATH system environment variable (see: add ADB to path variable).

您还可以使用以下方法重置/撤消特定权限:

You can also reset/revoke a specific permissions using:

adb shell pm revoke com.your.package android.permission.WRITE_EXTERNAL_STORAGE

此命令的缺点是它将重新启动您的应用程序,但这不会重置所有应用程序的运行时权限.要授予权限,请用grant替换revoke.

A downside of this command is that it will restart your app, but this doesn't reset the runtime permissions for all apps. To grant a permission replace revoke with grant.

这篇关于如何调试/重置Android 6.0权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆