Uploading image in the android app is alway trick and one need to handle all those out of memory exception or other issues. Normally we use image-choose-library to upload image in our android applications using ImageView as the view. Image-choose-library is very simple to use as it needs to write less code and have several other properties such as:
- Supports picking up images/videos from phone gallery.
- Supports capturing images/videos using the phone camera.
- Generates thumb-nails for the any chosen media.
- (New) Supports picking up files in general.
- Similar code base to implement irrespective of Android version of device.
For image-chooser-libary include the following line in your gradle.
compile 'com.kbeanie:image-chooser-library:[email protected]'
The image-choose-library is proved to be very helpful for us,but we came to a problem when we used SimpleDraweeView as view of fresco library. Fresco supports the following uri – file:// for files on device .When we were using the image-chooser-library it was not building the uri that it supports.We worked on the issue and come to the solution that we are going to share with you .
Upload Image Using Facebook Fresco with image choose library:
For using fresco in your application include the following code in your gradle:
For the imageView we were using the following code to build the uri :
For SimpleDraweeView we used the following code:
imageUpload.setImageURI(Uri.parse("file://" + new File(image .getFilePathOriginal()).toString()));
For the complete code click here. You are welcome to fork the source code or reuse it in your android Apps.
Use of SimpleDraweeView of fresco library in image-chooser library has given a new concept to us .This is an article to demonstrate the use of image-choose-library with fresco’s SimpleDraweeView as view.