Media Picker is an Android Libary that lets you to select multiple images, video or voice for Android 4.1 (API 16) +. You can report any issue on issues page. Note: If you speak Arabic, you can submit issues with Arabic language and I will check them. :)
Maven
<dependency>
<groupId>net.alhazmy13.MediaPicker</groupId>
<artifactId>libary</artifactId>
<version>1.2.3</version>
</dependency>
Gradle
dependencies {
compile 'net.alhazmy13.MediaPicker:libary:1.2.3'
}
After adding the library, you need to:
- Implement an
OnImageSetListener
- Create an object from
ImagePicker
In order to receive the path of image, you will need to implement the OnImageSetListener
interfaces. Typically this will call camera activity and return the path of image.
@Override
public void onImageSet(String path) {
//imageView.setImageBitmap(BitmapFactory.decodeFile(path));
}
You will need to create a new instance of ImagePicker
. Once the instance are configured, you can call pick()
.
new ImagePicker.Builder(MainActivity.this)
.setOnImageSetListener(this)
.pick();
setMode
to select the mode, you can chose one ot theseCAMERA
,GALLERY
orCAMERA_AND_GALLERY
.setMode(ImagePicker.Mode.CAMERA)
setExtanion
You can change the extanion of image toPNG
orJPG
.setExtension(ImagePicker.Extension.PNG)
setCompressLevel
You can change the quality of image with three different levelsHARD
,MEDIUM
,SOFT
orNONE
.setCompressLevel(ImagePicker.ComperesLevel.MEDIUM)
setDirectory
You can pass the storage path, or You can selectDirectory.DEFAULT_DIR
to keep the default path.
.setDirectory(ImagePicker.Directory.DEFAULT)
//OR
.setDirectory(Environment.getExternalStorageDirectory()+"/myFolder")
After adding the library, you need to:
- Implement an
OnVideoSetListener
- Create an object from
VideoPicker
In order to receive the path of video, you will need to implement the OnVideoSetListener
interfaces. Typically this will call camera activity and return the path of video.
@Override
public void OnVideoSet(String path) {
//
}
You will need to create a new instance of VideoPicker
. Once the instance are configured, you can call pick()
.
VideoPicker videoPicker=new VideoPicker(this);
videoPicker.setOnVideoSetListener(this);
videoPicker.pick();
SetExtanion
You can change the extanion of video toMp4
,3gp
ormkv
videoPicker.setExtension(VideoPicker._MP4);
setDirectory
You can pass the storage path, or You can selectVideoPicker.DEFAULT_DIR
to keep the default path.
videoPicker.setDirectory(VideoPicker.DEFAULT_DIR);
//OR
videoPicker.setDirectory(Environment.getExternalStorageDirectory()+"/myFolder");
You can change the strings be overwriting below resources in your project.
<string name="media_picker_select_from">Select From:</string>
<string name="media_picker_camera">Camera</string>
<string name="media_picker_gallery">Gallery</string>
Copyright 2015 alhazmy
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.