HomeAndroidAndroid Builders Weblog: Picture Picker All over the place

Android Builders Weblog: Picture Picker All over the place



Posted by Yacine Rezgui – Developer Relations Engineer

Enhancing privateness stays a prime precedence on Android. We have been investing within the platform to provide customers extra management, enhance transparency, and cut back the scope of entry to personal knowledge.

Final yr, we launched a brand new function to emphasise this technique: the Android picture picker. The picture picker is a browsable interface that presents the person with their media library, sorted by date from latest to oldest, and integrates properly along with your app’s expertise with out requiring media storage permissions!

 Moving image showing screengrab of Photo Picker on a mobile device

It permits customers to browse their picture gallery and grant entry to particular gadgets to an app. It’s a strong software permitting you to shortly add a photograph choice function to your apps with out having to develop a posh in-house picker from scratch. It additionally eliminates the necessity to keep advanced logic for dealing with permissions and querying MediaStore, enabling you to save lots of effort and time that will in any other case be spent on coding and debugging.

The picture picker is simple to implement, as you solely want to incorporate a couple of traces of code with the assist library. Moreover, it’s extremely configurable, so you possibly can customise the person expertise in keeping with your app’s particular wants.

What’s new?

Availability throughout all Android variations

One key piece of suggestions we’ve heard from builders is the shortage of assist for older gadgets, making upkeep pricey when it comes to growth. We’re happy to announce that, as a part of the ActivityX 1.7.0 launch, the Picture Picker assist library will use a backported model supplied by Google Play providers on gadgets operating Android KitKat (4.4) and later!

To allow the backported picture picker:


<service android:title="com.google.android.gms.metadata.ModuleDependencies" android:enabled="false" android:exported="false">
<intent-filter>
<motion android:title="com.google.android.gms.metadata.MODULE_DEPENDENCIES" />
</intent-filter>

<meta-data android:title="photopicker_activity:0:required" android:worth="" />
</service>

Register an exercise end result with PickVisualMedia or PickMultipleVisualMedia and launch the picture picker.


val pickMultipleVisualMedia = registerForActivityResult(PickMultipleVisualMedia(5)) { uris ->

Log.d("Picture Picker URIs depend", uris.measurement)
}

pickMultipleVisualMedia.launch(PickVisualMediaRequest(PickVisualMedia.ImageAndVideo))

And that’s it! In lower than 10 traces of code, you’ve got a permission-less picture picker with a pleasant UX that blends effectively into your utility, and you’ve got a single code path for sustaining the function’s performance for all Android variations operating KitKat and above.

GET_CONTENT takeover

Since our final weblog submit, we began rolling out assist for the GET_CONTENT intent within the Android picture picker at any time when the desired MIME kind filter matches picture/* and/or video/*. Because the rollout will proceed within the upcoming months, make certain to check your app as soon as your system has the function enabled:

adb shell device_config put storage_native_boot take_over_get_content true

Later this yr, the picture picker will seamlessly assist cloud storage suppliers like Google Images, permitting customers to pick their distant content material with out having to depart your app, and with none code change on the builders facet.

In case you have any suggestions or strategies, submit tickets to our difficulty tracker.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments