android - 如何授予调试的android应用程序权限?

标签 android debugging geolocation android-permissions

我有

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

在我的 list 中,但尽管如此,我的代码跟踪表明了这种情况

 if (ActivityCompat.checkSelfPermission(this,
                android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
                ActivityCompat.checkSelfPermission(this,
                        android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {

true,即两种权限均未授予。

那怎么授予呢?

更新

我的应用程序的逻辑假定不请求权限。如果它们被授予,那么它将以一种方式工作,如果它们没有被授予,它将在没有它们的情况下默默地工作。

因此,我需要像安装应用程序一样授予它们并在安装期间授予权限。

更新 2

我怀疑答案在 Android StudioRun/Debug configurations 中。

例如,我在调试时在控制台中看到以下行

adb shell pm install -r "MYPATH"

还有我在这里看到https://developer.android.com/studio/command-line/adb.html#pm -g 选项表示“授予应用程序 list 中列出的所有权限”。

这是我需要自动发生的事情。

最佳答案

目前我找到了以下解决方案并且有效

enter image description here

关于android - 如何授予调试的android应用程序权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41768081/

相关文章:

android - 无法从 Gmail 发送 .zip 文件

.net - 是否有可能从转储中获取引发异常的行?

c++ - 如何在 Windows 10 操作系统上使用 Bazel 调试 C++ 代码

python - Wing IDE 不会在 Google App Engine 的断点处停止

javascript - 如果选中复选框,则获取当前位置

ruby-on-rails - Rails GeoCoder,循环遍历现有数据库和 geocode_by :address, :city, :state

java - 多个dex文件定义Landroid/arch/lifecycle/LiveData$LifecycleBoundObserver;

java - 在Android中使用addView输出文本结果?

android - 如果我有 id 或 threadId,我可以在 Gmail 应用程序中打开我的电子邮件线程吗?

html - 为什么 html5 地理定位无法获得结果?