Trying to target Android R (API 30) using scoped storage. I get the image picker to open the media library to allow user to select 1 or more images using:
new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
I get the list of Uris e.g.
content://com.android.providers.media.documents/document/image%3A189
content://com.android.providers.media.documents/document/image%3A190
I then attempt to generate the intent to ask permission to delete:
PendingIntent intent = MediaStore.createDeleteRequest(getContentResolver(), uris);
But this throws the exception:
java.lang.IllegalArgumentException: All requested items must be referenced by specific ID
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
at android.content.ContentProviderProxy.call(ContentProviderNative.java:732)
at android.content.ContentResolver.call(ContentResolver.java:2405)
at android.provider.MediaStore.createRequest(MediaStore.java:822)
at android.provider.MediaStore.createDeleteRequest(MediaStore.java:985)
...
How is one to convert the Uris into the special format expected by MediaStore.createDeleteRequest?