Skip to content

j4velin/PictureChooser

Repository files navigation

PictureChooser

Build Status

Usage

Add to your gradle.build file:

dependencies {
    compile 'com.github.j4velin.PictureChooser:picturechooser:+'
}

Start with

startActivityForResult(new Intent(context, de.j4velin.picturechooser.Main.class), PICTURE_CHOOSER);

and read the "imgPath" StringExtra from the Intent you get in onActivityResult. To allow the user to crop the image (which will create a copy of the image in your apps directory), add the optional boolean extra "crop" with value "true" to the intent. You can also provide int-extras "aspectX" and "aspectY" to enforce a given aspect ratio on the cropped image.

Example

private final static int ADD_IMAGE = 1;
    
findViewById(R.id.button).setOnClickListener(new OnClickListener() {
    public void onClick(final View v) {
    startActivityForResult(
        new Intent(context, de.j4velin.picturechooser.Main.class)
        // following 3 lines are optional
            .putExtra("crop", true)
            .putExtra("aspectX", 16)
            .putExtra("aspectY", 9), 
        ADD_IMAGE);
    }
});
  
....
  
protected void onActivityResult(int request, int result, final Intent data) {
    if (result == RESULT_OK && request == ADD_IMAGE) {
        String path = data.getStringExtra("imgPath");
        ...
    }
}

Build

Add the Android support library to build the project

Apps using this library

Please send a pull request if your app uses this library

About

A simple picture chooser library for Android

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages