Reputation: 450
I am trying gaining permission reading and writing on the external storage:
<uses-feature android:name="android.hardware.camera.any" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE "/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Code for asking for permission:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//works. dialog pops up
ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 101);
//doesnt work. dialog does not pop
ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 565);
}
But I have an issue: The issue is that I am only "allowed" to allow permission for reading the storage, not writing in this. The dialog does pop up when asking for writer permissions. Am I missing something? I know that u have to ask for the permission if the sdk version is higher than marshmellow. The permission ask also happens during runtime (onClick listener).
Upvotes: 0
Views: 490
Reputation: 347
I fixed by adding tools:remove="android:maxSdkVersion" like this:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:remove="android:maxSdkVersion"/>
Upvotes: 1
Reputation: 539
In manifest have to add these line after adding line you can show all data
requestLegacyExternalStorage=true
Upvotes: 0