Skip to content

ligboy/selectphoto

Repository files navigation

selectphoto

Build Status Download Select a photo activity for android by stock camera or photos

Download

This library already included in JCenter & MavenCentral

Gradle:

compile 'org.ligboy.android:selectphoto:1.1.1'

Usage

  1. Define String res: @string/sp_provider_authorities, This is the authorities of the FileProvider for capture picture.

  2. Define a Theme:

    <style name="AppTheme.Transparent">
        <item name="android:windowIsTranslucent">true</item>
    </style>
  1. Add SelectImageActivity to AndroidManifest.xml
    <activity android:name="org.ligboy.selectphoto.SelectImageActivity"
        android:theme="@style/AppTheme.Transparent"/>
  1. Let's start it
    SelectImageActivity.builder()
            .asSquare()
            .setFixAspectRatio(true)
            .withMaxSize(1024, 1024)
            .withCrop(true)
            .start(MainActivity.this);

OnActivityResult:

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == SelectImageActivity.REQUEST_CODE_SELECT_IMAGE
                && resultCode == Activity.RESULT_OK && data != null && data.getData() != null) {
            Uri uri = data.getData(); //The image uri.
        } else {
            super.onActivityResult(requestCode, resultCode, data);
        }
    }

About

Select a photo activity for android by stock camera or photos

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages