Search code examples
androidandroid-intentandroid-api-levels

does an intent behave differently depending on Android API level?


I use Intent.ACTION_GET_CONTENT with putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true) to retrieve multiple images from the system (not specifically from the Gallery app, but just from recent tab for general images). I just went through each Android API level from 27(Oreo) to 32(Snow Cone). I found the behavior is not predictable. For example, when I am to retrieve multiple images from system call in all Android APIs but 28(between 27 to 32), system shows recent images and allow me to choose multiple images once I start long-click on an image. However, it does not show me any images (even I have some images in default photo app) in Recent tab when I try to retrieve multiple images from system call. I had to navigate to default photo app to find images. It allows me to choose multiple images though once I get to those image files through default photo app.

I wonder if this is really expected behavior out of these Android API levels. (why the behavior is different only in Android API 28? while the behavior in 27, 29, 30, 31, and 32 is consistent. like why 27 and 28 are not consistent? 28 is between 27 and 29. but why only 28 behaves differently?)

I used emulator device Pixel 4 in android studio just changing the Android API level to test the behavior.

I will appreciate your help in advance.


Solution

  • I use Intent.ACTION_GET_CONTENT with putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true) to retrieve multiple images from the system (not specifically from the Gallery app, but just from recent tab for general images).

    Whether there is a "recent tab for general images" will vary by device.

    I wonder if this is really expected behavior out of these Android API levels.

    The behavior of an Intent will vary by device. The Android SDK documentation provides a very general contract regarding input and output in the form of Uri values, extras, etc. What the UI will be is up to Google (for the OS version), the device manufacturer, and in some cases the user. You should not be making any assumptions about what that UI will look like.