KutuPicker is a android image picker library using Camera & Gallery.
- Add in project level
build.gradle
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' } // This Line
}
}
- Add in module level
build.gradle
dependencies {
implementation 'ninja.sakib:KutuPicker:1.0.1'
}
- Start Image Picker
- Using Gallery
Intent i = new Intent(getApplicationContext(), GalleryPickerActivity.class);
i.putExtra(CodeUtil.MAX_SELECTION, 5);
i.putExtra(CodeUtil.MIN_SELECTION, 1);
startActivityForResult(i, CodeUtil.IMAGE_SELECTION_REQUEST_CODE);
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == CodeUtil.IMAGE_SELECTION_DONE) {
ArrayList<String> selectedImages = data.getStringArrayListExtra(CodeUtil.SELECTED_IMAGES_KEY);
for (String image : selectedImages) {
Log.d("Selected", image);
}
}
}
- Using Camera
Intent i = new Intent(getApplicationContext(), CameraPickerActivity.class);
i.putExtra(CodeUtil.MAX_SELECTION, 5);
i.putExtra(CodeUtil.MIN_SELECTION, 1);
startActivityForResult(i, CodeUtil.IMAGE_SELECTION_REQUEST_CODE);
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == CodeUtil.IMAGE_SELECTION_DONE) {
ArrayList<String> selectedImages = data.getStringArrayListExtra(CodeUtil.SELECTED_IMAGES_KEY);
for (String image : selectedImages) {
Log.d("Selected", image);
}
}
}
Copyright © Sakib Sami
Distributed under MIT license