- Bug fix: For some files, when you get FileNotFoundException, fixed a null pointer exception.
- Feature: Send back the filepath, to the caller while using camera for video/image. This should be used when you want to support orientation changes.
- Bug Fix for versions <3.0 Pull Request:Juan Andrés
- Added choosing video from gallery (supports both locally stored videos and your picasa videos).
- Added taking a video using camera.
- Gives back the actual video path, and two thumbnails.
Sample App using the library v1.2
Link to image-chooser-library v1.2
- Added optional output folder configuration.
- Added folder cache limit and auto delete old files.
- Added an optional flag to control thumbnail generation.
Link to image-chooser-library v1.1
- Supports adding images by using the device's camera.
- Supports adding pictures from the Camera folder of your gallery.
- Supports adding pictures from your synced Picasa folders on your phone.
- Supports 3 types of image output sizes (Original, Thumbnail and Thumbnail smaller).
- Your app should have internet permission.
- WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE permissions are required.
- Clone this repository and add this as a dependency to your Android project. This is a library project.
- Download the jar file, and add it to your Android project's build path
For choosing an image from gallery
imageChooserManager = new ImageChooserManager(this, ChooserType.REQUEST_PICK_PICTURE);
imageChooserManager.setImageChooserListener(this);
imageChooserManager.choose();
For capturing a picture using your camera
imageChooserManager = new ImageChooserManager(this, ChooserType.REQUEST_CAPTURE_PICTURE);
imageChooserManager.setImageChooserListener(this);
imageChooserManager.choose();
On Activity result, do this:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK &&
(requestCode == ChooserType.REQUEST_PICK_PICTURE ||
requestCode == ChooserType.REQUEST_CAPTURE_PICTURE)) {
imageChooserManager.submit(requestCode, data);
}
}
Implement the ImageChooserListener interface
Override these methods:
@Override
public void onImageChosen(final ChosenImage image) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (image != null) {
// Use the image
// image.getFilePathOriginal();
// image.getFileThumbnail();
// image.getFileThumbnailSmall();
}
}
});
}
@Override
public void onError(final String reason) {
runOnUiThread(new Runnable() {
@Override
public void run() {
// Show error message
}
});
}
For capturing a video using your camera
videoChooserManager = new VideoChooserManager(this, ChooserType.REQUEST_CAPTURE_VIDEO);
videoChooserManager.setVideoChooserListener(this);
videoChooserManager.choose();
For selecting a video from your gallery
videoChooserManager = new VideoChooserManager(this, ChooserType.REQUEST_PICK_VIDEO);
videoChooserManager.setVideoChooserListener(this);
videoChooserManager.choose();
On Activity result, do this:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK &&
(requestCode == ChooserType.REQUEST_PICK_VIDEO ||
requestCode == ChooserType.REQUEST_CAPTURE_VIDEO)) {
videoChooserManager.submit(requestCode, data);
}
}
Implement the VideoChooserListener interface
Override these methods:
@Override
public void onVideoChosen(final ChosenVideo video) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (video != null) {
// Use the video
// video.getFilePathOriginal();
// video.getFileThumbnail();
// video.getFileThumbnailSmall();
}
}
});
}
@Override
public void onError(final String reason) {
runOnUiThread(new Runnable() {
@Override
public void run() {
// Show error message
}
});
}
Copyright 2013 Kumar Bibek
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.