Repository navigation
Documentation (v1.x)
Bohdan Semeniuk edited this page Sep 4, 2016
·
2 revisions
v1.x API is @Deprecated but functional
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile 'com.github.aviadmini:quickimagepick:2.0.0'
}v2.0.0 contains fixes to old API as well, thus is best one to use
- Use one of
QuickImagePick.pickFromGallery(...)methods - Choose allowed MIME types of files that can be picked
- Use one of
QuickImagePick.pickFromDocuments(...)methods - Note: on pre-KitKat this will show file manager apps to choose a picture
- Choose allowed MIME types of files that can be picked
- Use one of
QuickImagePick.pickFromCamera(...)methods - You can change the directory where pictures are saved by calling
setCameraPicsDirectory(Context pContext, String pDirPath), set tonullto use default (pictures directory on external storage) - EXTREMELY IMPORTANT: library does not delete the images taken by camera. You must do it yourself after you're done with them to prevent using too much storage space
- Default settings don't need
WRITE_EXTERNAL_STORAGEpermission. But if you want to save camera pics to a different location you might need to grant the permission - Library does not need CAMERA permission. However if you have it declared in your Manifest, you must grant it to use
pickFromCamera(...)methods. Refer here
Use a combination of above by specifying which types to show PickSource.CAMERA, PickSource.GALLERY and/or PickSource.DOCUMENTS (refer to sample app for usage)
QuickImagePick.pickFromMultipleSources(...)
final QuickImagePick.Callback mCallback = new QuickImagePick.Callback() {
@Override
public void onImagePicked(@NonNull final PickSource pPickSource, final int pRequestType, @NonNull final Uri pImageUri) {
Log.i(TAG, "Picked: " + pImageUri.toString());
// Do something with Uri, for example load image into and ImageView
Glide.with(getApplicationContext())
.load(pImageUri)
.fitCenter()
.into(mImageView);
}
@Override
public void onError(@NonNull final PickSource pPickSource, final int pRequestType, @NonNull final String pErrorString) {
Log.e(TAG, "Err: " + pErrorString);
}
@Override
public void onCancel(@NonNull final PickSource pPickSource, final int pRequestType) {
Log.d(TAG, "Cancel: " + pPickSource.name());
}
};
@Override
protected void onActivityResult(final int pRequestCode, final int pResultCode, final Intent pData) {
super.onActivityResult(pRequestCode, pResultCode, pData);
super.onActivityResult(pRequestCode, pResultCode, pData);
QuickImagePick.handleActivityResult(getApplicationContext(), pRequestCode, pResultCode, pData, this.mCallback);
}UriUtils.saveContentToFile(Context, Uri, File) throws IOException;QuickImagePick.allowOnlyLocalContent(boolean);QuickImagePick.setAllowedMimeTypes(Context, String...);
QuickImagePick.setAllowedMimeTypes(Context, List<String>);
QuickImagePick.setAllowedMimeTypes(Context, Set<String>);
QuickImagePick.setAllImageTypesAllowed(Context);UriUtils.getUriMimeType(Context, Uri);
UriUtils.getUriFileExtension(Context, Uri);UriUtils.deleteContent(Context, Uri);