7

I can create intent to choose image from gallery on Android in Kotlin like this:

val intentGallery = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI)
if (intentGallery.resolveActivity(activity.packageManager) != null) {
    // Launch the intent
}

What do I need to put in "queries" block in "AndroidManifest" file on Android 11 (API 30) for this code to work?

Adding this code to "queries" block in "AndroidManifest" file, will make it work just fine.

<package android:name="com.google.android.apps.photos" />

But I want to add a code that covers all image galleries, not just Google's.

Reference: https://developer.android.com/training/basics/intents/package-visibility

Harry
  • 323
  • 3
  • 10
  • Thank you CommonsWare, but I don't believe that would work. The result will always be null and it will always end up with ActivityNotFoundException. This is a very new thing in Android 11. Please check out the link in my post. – Harry Nov 02 '20 at 12:10
  • Intent.ACTION_PICK has nothing to do with package visibility. Please tell which problem you encounter. – blackapps Nov 02 '20 at 12:14
  • That is incorrect. For instance if I add this code to "queries" block in "AndroidManifest" file, it would work just fine, but without it it won't. But I want to add a code that covers all image galleries, not just Google's. – Harry Nov 02 '20 at 12:23
  • 1
    CommonsWare, your response is incorrect. I figured out the response and Jahongir posted as well. Good luck marketing your bad book. – Harry Dec 11 '20 at 13:43

1 Answers1

19
<queries>
    <intent>
        <action android:name="android.intent.action.PICK" />
        <data android:mimeType="vnd.android.cursor.dir/image" />
    </intent>
</queries>

I hope this will help. I used this query parameters and it's works fine