Skip to content
📱An Android photo picker to search and download photos from Unsplash.
Branch: master
Clone or download
Latest commit ac2b804 May 9, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE Update issue templates Apr 17, 2019
example Added logging option Apr 16, 2019
gradle/wrapper Created android studio project Jan 26, 2019
photopicker
.gitignore Created gitignore Jan 26, 2019
LICENSE Create LICENSE Jan 26, 2019
README.md Update README.md May 9, 2019
build.gradle Add integration with Bintray. Apr 23, 2019
gradle.properties Created android studio project Jan 26, 2019
gradlew Created android studio project Jan 26, 2019
gradlew.bat Created android studio project Jan 26, 2019
settings.gradle Renamed example app module Jan 26, 2019
unsplash-photo-picker-android.png Update the README file. Apr 17, 2019

README.md

Unsplash Photo Picker for Android

License Download

UnsplashPhotoPicker is an Android UI component that allows you to quickly search the Unsplash library for free high-quality photos with just a few lines of code.

iOS photo picker here.

Unsplash Photo Picker for Android preview

Table of Contents

Description

UnsplashPhotoPicker is a Kotlin object you use to initialize the library. You present the picker by navigating to the UnsplashPickerActivity to offer your users to select one or multiple photos from Unsplash. Once they have selected photos, the UnsplashPickerActivity returns UnsplashPhoto objects that you can use in your app.

Requirements

Installation

Gradle

To integrate UnsplashPhotoPicker into your Android Studio project using Gradle, specify in your project build.gradle file:

allprojects {
   repositories {
      maven { url  "https://dl.bintray.com/unsplash/unsplash-photopicker-android" }
   }
}

And in your app module build.gradle file:

dependencies {
   implementation 'com.unsplash.pickerandroid:photopicker:x.y.z'
}

Usage

❗️Before you get started, you need to register as a developer on our Developer portal. Once registered, create a new app to get an Access Key and a Secret Key.

Configuration

The UnsplashPhotoPicker is a Kotlin object you need to use in order to initialize the library. Add this in your custom application class onCreate method:

UnsplashPhotoPicker.init(
            this, // application
            "your access key",
            "your secret key"
            /* optional page size */
        )
Property Type Optional/Required Default
application Application Required N/A
accessKey String Required N/A
secretKey String Required N/A
pageSize Int Optional 20

Presenting

In order to access the picker screen you need to navigate to the UnsplashPickerActivity. This activity has a getStartingIntent method to create the Intent needed:

startActivityForResult(
                UnsplashPickerActivity.getStartingIntent(
                    this, // context
                    isMultipleSelection
                ), REQUEST_CODE
            )

Using the results

Your calling activity must use a startActivityForResult method to be able to retrieve the selected UnsplashPhoto:

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CODE) {
            val photos: ArrayList<UnsplashPhoto>? = data?.getParcelableArrayListExtra(UnsplashPickerActivity.EXTRA_PHOTOS)
            // use your photos here
        }
}

See UnsplashPhoto.kt for more details.

License

MIT License

Copyright (c) 2019 Unsplash Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You can’t perform that action at this time.