if (ContextCompat.checkSelfPermission(RegisterActivity.this, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_DENIED){
ActivityCom
<!--Declaring the required permissions-->
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.CAMERA" />
Then go to next steps..
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 <uses-permission>
in my manifest to:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:remove="android:maxSdkVersion"/>
(where the tools namespace is http://schemas.android.com/tools
)
For me the problem was that right after making the request, my main activity launched another activity. That superseded the dialog so it was never seen.
The above information is good, but setting targetSdkVersion
to 23 (or higher) is critical for Android to interpret the <uses-permission>
tag in the manifest as "I will ask in code" instead of "I demand upon installation." Lots of sources will tell you that you need the <uses-permission>
tag, but no one says why and if you don't have that value set, you're going to be as confused as I was for hours on end.
I had this same issue.I updated to buildToolsVersion "23.0.3" It all of a sudden worked. Hope this helps anyone having this issue.
I updated my target SDK version from 22 to 23 and it worked perfectly.