Permissionless is the future of Storage on Android | by Yacine Rezgui | Android Developers | Oct, 2022

Dhanisa Mashilfa

No matter if it’s to improve a profile avatar, share trip pics, or insert an attachment to an e mail, deciding on and sharing media documents are just one of the most common factors users do on mobile apps. Soon after listening to feedback from Android end users, we’ve produced a few adjustments to how applications entry media data files. And centered on what we have discovered from talking to developers, we’ve released a practical new device.

At Android, we imagine inquiring people to find photographs and movies should be useful, uncomplicated to put into practice, and privacy acutely aware.

Quite a few end users instructed us that the Data files & Media authorization bothers them, because they never know which data files the application would like accessibility to.

On Android 13, we’re deprecating Examine_External_STORAGE and Publish_External_STORAGE permissions in favour of improved alternate APIs for media file access.

Continue to keep in thoughts that you don’t need any permission to incorporate files to shared storage from Android 10. So if your app only adds documents in the shared storage, you can end requesting any permission on Android 10+

Traditionally, applications asked for Browse_External_STORAGE to inquire customers to grant entry to Documents & Media. Then, they executed their own media finding working experience, including weighty growth & upkeep costs to the developer workforce. Alternatively, apps relied on the procedure file picker by way of Motion_GET_Material or Motion_Open_Written content, but we have read from builders that it didn’t sense well-integrated to their apps UX:

System File Picker using ACTION_OPEN_CONTENT
Process File Picker applying Motion_Open up_Articles

In Android 13, we introduced a new visible media picking device: the Android photo picker. This resource provides a way for buyers to pick out media information, devoid of needing to grant access to their complete media library.

It offers a clean up, browsable interface that presents the user with their pictures and films, sorted by day. In addition the “Albums” segment allows buyers browse by helpful categories like Screenshots or Downloads. The picture picker is customisable by specifying if consumers must see only pictures or only video clips, or by setting a most amount of things they can find. In quick, this solution is non-public by style, has a clean up and integrated UX & is simple to carry out.

We’ve also backported the image picker on Android 11 & 12* by means of a Google Engage in system update (1 May 2022 launch) to convey it to a broader Android audience.

Even though constructing your individual media picker is a complex and laborious challenge to create and update, the photo picker doesn’t demand any maintenance from your group. It is a very simple intent to be released and we have presently made an ActivityResultContract for it in the ActivityX 1.6. launch. It will use the photograph picker when readily available and fallback to Motion_Open up_Doc on more mature equipment:

// Registering Picture Picker exercise launcher with a max limit of 5 goods
val pickMultipleVisualMedia = registerForActivityResult(PickMultipleVisualMedia(5)) uris ->
// TODO: process URIs
// Launching the picture picker (pics & online video bundled)
pickMultipleVisualMedia.start(PickVisualMediaRequest(PickVisualMedia.ImageAndVideo))

If you are wanting to include a variety filtering, you can do it this way:

// Launching the picture picker (images only)
pickMultipleVisualMedia.start(PickVisualMediaRequest(PickVisualMedia.ImageOnly))
// Launching the photo picker (movie only)
pickMultipleVisualMedia.launch(PickVisualMediaRequest(PickVisualMedia.VideoOnly))
// Launching the image picker (GIF only)
pickMultipleVisualMedia.launch(PickVisualMediaRequest(PickVisualMedia.SingleMimeType("image/gif")))

You can validate no matter if the picture picker is offered on a provided unit by contacting isPhotoPickerAvailable.

Verify out the documentation for more facts on incorporating the photo picker to your application.

As we just observed, adopting the Android photo picker needs just a several traces of code. Although we want all applications to use it, migration might consider some time in your application. That is why we are bringing the rewards of Android photograph picker to present apps using Action_GET_Content by switching the program file picker for the picture picker less than the hood without having any code alter demanded in the forthcoming months. If you launch the Action_GET_Information intent with an picture and/or movie mime style filter, the photograph picker will be shown rather of the doc picker. For apps, the anticipated intent final results will be the similar: a record of Uri.

Action_GET_Material will open the image picker in its place of the doc picker

When we strongly endorse you to use the new photograph picker about requesting obtain to all media data files, your app may possibly have a use circumstance demanding this wide accessibility (e.g. gallery image backup). For these distinct usages, we’re introducing new permissions that provide accessibility to precise styles of media documents, including photos, video clip, or audio. You can read through extra about them in the documentation.

If the consumer beforehand granted your application the Examine_Exterior_STORAGE authorization, the method quickly grants the granular media permissions to your app. If not, the system displays a consumer-experiencing dialog when your app requests any of the new permissions.

Continue to keep in mind that you must generally look at if any permissions are still granted relatively than storing their grant states. With application hibernation and expiring authorization grants

Look at out this conclusion tree to enable you navigate by means of these modifications:

With these bulletins, we’re fully commited to continue to keep enhancing the picture picker and general storage developer encounter although shielding person privacy to produce a safe and transparent Android ecosystem. If you have any feedback or tips, submit tickets to our issue tracker!

*: The Android picture picker is backported to all Android 11 & 12 devices, excluding Android Go and non-GMS gadgets.

Next Post

Migrating the AOSP QuickSearchBox App to Kotlin | by Android Developers | Android Developers | Sep, 2022

submitted by Ryan O’Leary, Android Intern For the past three years, the Android Open Source Project (AOSP) applications team has taken on the task of converting AOSP apps from Java to Kotlin. This pursuit was begun as part of Android’s commitment to increasingly develop with Kotlin-first. Kotlin is a safe, […]
Migrating the AOSP QuickSearchBox App to Kotlin | by Android Developers | Android Developers | Sep, 2022