New OneDrive SDK: announcing the Android open file picker

Share on Facebook Share on Twitter Share on Linkedin Share via OneNote Share via Email Print

One of the most basic and common things to do with OneDrive is opening a file, but sadly doing this simple operation hasn’t been so simple for developers. We recognized this pain point and are excited to finally release the Android open picker to make this common task easy and seamless for developers and OneDrive users.

Before, a developer would waste precious time building UI and all the other components of a file picker just to let their users select a file from OneDrive. Our goal here was to give you this time back.

With the Android open picker, you can get started opening files in minutes instead of days. The picker lets you get links to download file content directly or view links that are great for sharing, as well as a set of thumbnails for image files.

The Android file picker flow.

To get started, download the SDK (or view on GitHub) and  add a couple lines of code to your Android app. You now have the native OneDrive Android experience for opening files ready to go and billions of files in OneDrive and OneDrive for Business at your fingertips.  No need to handle OAuth, no need to implement file hierarchy traversal and your own UI.

The OneDrive picker for Android also works on Ice Cream Sandwich and beyond—so  your users will have the same great file opening experience, whatever their flavor of Android.

Quickstart with the Android picker

To start opening files from OneDrive using the SDK, set up a click handler that launches the open picker from onClick(). The snippet below requests a download link using LinkType.DownloadLink (replace with LinkType.WebViewLink to get a shareable link for web viewing).

This code snippet launches the OneDrive picker using the startPicking() method as soon as onClick() is invoked.

All that is left is to catch the results of the picker. When the user selects a file to open or cancels from the picker, the onActivityResult() method will be called to handle the results.

Using this code, you can get access to data about the opened file in result like filename using result.getName(), the link to the file requested using result.getLink(), and thumbnails for images and viedos using result.getThumnailLinks().

That’s all you need to get started after downloading the SDK! For more information about using the Android open picker SDK, check out the OneDrive Dev Center or OneDrive on GitHub.

We are excited to see what you build with the Android open picker! Connect with us on Stack Overflow (tag onedrive) or GitHub as you get started!