ActivityCompat.requestPermissions not showing dialog box

前端 未结 20 1531
野趣味
野趣味 2020-12-07 17:15
if (ContextCompat.checkSelfPermission(RegisterActivity.this,      Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_DENIED){
            ActivityCom         


        
20条回答
  •  天涯浪人
    2020-12-07 17:51

    I had the same issue and it turned out to be due to the manifest merger tool pulling in an android:maxSdkVersion attribute from a dependency.

    To view the actual permissions you're requesting in your APK you can use the aapt tool, like this:

    /path/to/android-sdk/build-tools/version/aapt d permissions /path/to/your-apk.apk
    

    in my case, it printed:

    uses-permission: name='android.permission.WRITE_EXTERNAL_STORAGE' maxSdkVersion='18'
    

    even though I hadn't specified a maxSdkVersion in my manifest. I fixed this issue by changing in my manifest to:

    
    

    (where the tools namespace is http://schemas.android.com/tools)

提交回复
热议问题