├── .gitignore ├── LICENSE.md ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── net │ │ └── alhazmy13 │ │ └── mediapickerexample │ │ ├── ImageFragment.java │ │ ├── MainActivity.java │ │ └── VideoFragment.java │ └── res │ ├── layout │ ├── activity_main.xml │ ├── image_layout.xml │ └── video_layout.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── comman ├── .gitignore └── build.gradle ├── deps.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── libary ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── net │ │ └── alhazmy13 │ │ └── mediapicker │ │ ├── FileProcessing.java │ │ ├── Image │ │ ├── ImageActivity.java │ │ ├── ImageConfig.java │ │ ├── ImagePicker.java │ │ ├── ImagePickerBuilderBase.java │ │ ├── ImageProcessing.java │ │ └── ImageTags.java │ │ ├── Utility.java │ │ └── Video │ │ ├── VideoActivity.java │ │ ├── VideoConfig.java │ │ ├── VideoPicker.java │ │ ├── VideoPickerBuilderBase.java │ │ ├── VideoProcessing.java │ │ └── VideoTags.java │ └── res │ ├── values-ar │ └── string.xml │ ├── values │ ├── strings.xml │ └── style.xml │ └── xml │ └── provider_paths.xml ├── license ├── rxjava ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── net │ │ └── alhazmy13 │ │ └── mediapicker │ │ └── rxjava │ │ ├── image │ │ ├── ImagePickerHelper.java │ │ ├── ImagePickerObservable.java │ │ └── ImagePickerReceiver.java │ │ └── video │ │ ├── VideoPickerHelper.java │ │ ├── VideoPickerObservable.java │ │ └── VideoPickerReceiver.java │ └── res │ └── values │ └── strings.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # Windows thumbnail db 19 | Thumbs.db 20 | 21 | # OSX files 22 | .DS_Store 23 | 24 | # Android Studio 25 | *.iml 26 | .idea 27 | #.idea/workspace.xml - remove # and delete .idea if it better suit your needs. 28 | .gradle 29 | build/ 30 | .navigation 31 | captures/ 32 | output.json #Since Android Studio 3.0 33 | 34 | #NDK 35 | obj/ 36 | .externalNativeBuild -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Abdullah Alhazmy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | # Media Picker 6 | ![](https://img.shields.io/badge/Platform-Android-brightgreen.svg) 7 | ![](https://img.shields.io/hexpm/l/plug.svg) 8 | ![](https://img.shields.io/badge/version-2.4.4-blue.svg) 9 | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/ea51407d60d04c938c263de206095abf)](https://www.codacy.com/app/me_101/MediaPicker?utm_source=github.com&utm_medium=referral&utm_content=alhazmy13/MediaPicker&utm_campaign=badger) 10 | 11 | 12 | **[Please let me know if your application go to production via this link](https://docs.google.com/forms/d/e/1FAIpQLSe4Y5Fwn1mlEoD4RxjXQzTvL4mofhESuBlTkAPQhI7J_WqMDQ/viewform?c=0&w=1)** 13 | ------ 14 | Media Picker is an Android Libary that lets you to select multiple images, video or voice for Android 4.1 (API 16) +. 15 | 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. :)** 16 | 17 | # NOTE 18 | ---- 19 | This build `2.x.x` will break backward compatibility and there are a lot of changes to improve the performance and fix a lot of Leak memory issues, So please read below document carefully. 20 | ## Installation 21 | ------ 22 | **Maven** 23 | 24 | ```xml 25 | 26 | net.alhazmy13.MediaPicker 27 | libary 28 | 2.4.4 29 | 30 | ``` 31 | 32 | 33 | **Gradle** 34 | 35 | ```gradle 36 | dependencies { 37 | implementation 'net.alhazmy13.MediaPicker:libary:2.4.4' 38 | } 39 | ``` 40 | 41 | # Usage 42 | ------ 43 | ## Images 44 | After adding the library, you need to: 45 | 46 | 1. Create an object from `ImagePicker` or `VideoPicker` 47 | 2. Override `onActivityResult` to receive the path of image or videos. 48 | 49 | 50 | 51 | ### Create an `ImagePicker` 52 | You will need to create a new instance of `ImagePicker`. Once the instance are configured, you can call `build()`. 53 | 54 | ```java 55 | new ImagePicker.Builder(MainActivity.this) 56 | .mode(ImagePicker.Mode.CAMERA_AND_GALLERY) 57 | .compressLevel(ImagePicker.ComperesLevel.MEDIUM) 58 | .directory(ImagePicker.Directory.DEFAULT) 59 | .extension(ImagePicker.Extension.PNG) 60 | .scale(600, 600) 61 | .allowMultipleImages(false) 62 | .enableDebuggingMode(true) 63 | .build(); 64 | ``` 65 | ### Override `onActivityResult ` 66 | In order to receive the path of image, you will need to override `onActivityResult ` . 67 | 68 | ```java 69 | @Override 70 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 71 | super.onActivityResult(requestCode, resultCode, data); 72 | 73 | if (requestCode == ImagePicker.IMAGE_PICKER_REQUEST_CODE && resultCode == RESULT_OK) { 74 | List mPaths = data.getStringArrayListExtra(ImagePicker.EXTRA_IMAGE_PATH); 75 | //Your Code 76 | } 77 | } 78 | ``` 79 | 80 | ### Additional Options 81 | * `mode` to select the mode, you can choose one of these `CAMERA`,`GALLERY` or `CAMERA_AND_GALLERY` 82 | 83 | ```java 84 | .mode(ImagePicker.Mode.CAMERA) 85 | ``` 86 | 87 | * `extension` You can change the extension of image to `PNG` or `JPG` 88 | 89 | ```java 90 | .extension(ImagePicker.Extension.PNG) 91 | ``` 92 | * `compressLevel` You can change the quality of image with three different levels `HARD`,`MEDIUM`, `SOFT` or `NONE` 93 | 94 | ```java 95 | .compressLevel(ImagePicker.ComperesLevel.MEDIUM) 96 | ``` 97 | 98 | * `directory` You can pass the storage path, or select `Directory.DEFAULT_DIR` to keep the default path. 99 | 100 | ```java 101 | .directory(ImagePicker.Directory.DEFAULT) 102 | 103 | //OR 104 | 105 | .directory(Environment.getExternalStorageDirectory()+"/myFolder") 106 | 107 | ``` 108 | 109 | * `scale` You can scale the image to a a minimum width and height. This will only be used if compressLevel is set. To avoid OutOfMemory issues, ensure this is used. 110 | 111 | ```java 112 | .scale(500, 500) 113 | ``` 114 | * `allowMultipleImages` Extra used to select and return multiple images from gallery **CANNOT select single image from gallery if this feature was enabled** 115 | 116 | ```java 117 | .allowMultipleImages(true) 118 | ``` 119 | 120 | * `enableDebuggingMode` used to print Image Picker Log 121 | 122 | ```java 123 | .enableDebuggingMode(true) 124 | ``` 125 | 126 | * `allowOnlineImages` an option to allow the user to select any image from online resource ex: Google Drive **(KNOWN ISSUE) if you enable this option then you cannot select multiple images** 127 | 128 | ```java 129 | .allowOnlineImages(true) 130 | ``` 131 | 132 | 133 | ### Create an `VideoPicker` 134 | You will need to create a new instance of `VideoPicker`. Once the instance are configured, you can call `build()`. 135 | 136 | ```java 137 | new VideoPicker.Builder(MainActivity.this) 138 | .mode(VideoPicker.Mode.CAMERA_AND_GALLERY) 139 | .directory(VideoPicker.Directory.DEFAULT) 140 | .extension(VideoPicker.Extension.MP4) 141 | .enableDebuggingMode(true) 142 | .build(); 143 | ``` 144 | ### Override `onActivityResult ` 145 | In order to receive the path of videos, you will need to override `onActivityResult ` . 146 | 147 | ```java 148 | @Override 149 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 150 | super.onActivityResult(requestCode, resultCode, data); 151 | 152 | if (requestCode == VideoPicker.VIDEO_PICKER_REQUEST_CODE && resultCode == RESULT_OK) { 153 | List mPaths = data.getStringArrayListExtra(VideoPicker.EXTRA_VIDEO_PATH); 154 | //Your Code 155 | } 156 | } 157 | ``` 158 | 159 | ### Additional Options 160 | * `mode` to select the mode, you can choose one of these `CAMERA`,`GALLERY` or `CAMERA_AND_GALLERY` 161 | 162 | ```java 163 | .mode(VideoPicker.Mode.CAMERA) 164 | ``` 165 | 166 | * `extension` You can change the extension of video to `MP4` 167 | 168 | ```java 169 | .extension(VideoPicker.Extension.MP4) 170 | ``` 171 | 172 | * `directory` You can pass the storage path, or select `Directory.DEFAULT_DIR` to keep the default path. 173 | 174 | ```java 175 | .directory(VideoPicker.Directory.DEFAULT) 176 | 177 | //OR 178 | 179 | .directory(Environment.getExternalStorageDirectory()+"/myFolder") 180 | 181 | ``` 182 | 183 | * `enableDebuggingMode` used to print Video Picker Log 184 | 185 | ```java 186 | .enableDebuggingMode(true) 187 | ``` 188 | 189 | ### RxJava 2 for MediaPicker 190 | 191 | It's an extenstion that allow you to return an observable from `ImagePickerBuilder` or `VideoPickerBuilder`, all you need is to add below dependency and then return the observable from `ImagePickerHelper` || `VideoPickerHelper` class. 192 | 193 | 194 | **Gradle** 195 | 196 | ```gradle 197 | dependencies { 198 | implementation 'io.reactivex.rxjava2:rxandroid:(Last_version)' 199 | implementation 'io.reactivex.rxjava2:rxjava:(Last_version)' 200 | implementation 'net.alhazmy13.MediaPicker:rxjava:(Last_version)' 201 | } 202 | ``` 203 | 204 | ```Java 205 | new ImagePickerHelper( 206 | new ImagePicker.Builder(Context) 207 | ...) 208 | .getObservable() 209 | .subscribe(....); 210 | ``` 211 | 212 | ------ 213 | 214 | 215 | ## Theme the pickers 216 | 217 | You can change the strings be overwriting below resources in your project. 218 | 219 | ```xml 220 | 221 | Select From: 222 | Camera 223 | Gallery 224 | Ok 225 | Cancel 226 | Some Permission is Denied 227 | You need to grant access to 228 | 229 | ``` 230 | 231 | 232 | 233 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | *.iml 3 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | //apply from: '../deps.gradle' 3 | 4 | android { 5 | compileSdkVersion 28 6 | 7 | defaultConfig { 8 | minSdkVersion 14 9 | targetSdkVersion 28 10 | applicationId 'net.alhazmy13.mediapickerexample' 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | 22 | lintOptions { 23 | abortOnError false 24 | } 25 | } 26 | 27 | dependencies { 28 | implementation "com.android.support:appcompat-v7:28.0.0" 29 | implementation "com.android.support:design:28.0.0" 30 | implementation "com.android.support:support-v13:28.0.0" 31 | implementation project(':libary') 32 | implementation project(':rxjava') 33 | implementation 'io.reactivex.rxjava2:rxandroid:2.0.2' 34 | implementation 'io.reactivex.rxjava2:rxjava:2.1.12' 35 | } 36 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/Alhazmy13/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/java/net/alhazmy13/mediapickerexample/ImageFragment.java: -------------------------------------------------------------------------------- 1 | package net.alhazmy13.mediapickerexample; 2 | 3 | import android.content.Intent; 4 | import android.graphics.BitmapFactory; 5 | import android.os.Bundle; 6 | import android.support.annotation.NonNull; 7 | import android.support.v4.app.Fragment; 8 | import android.util.Log; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.ImageView; 13 | import android.widget.TextView; 14 | 15 | import net.alhazmy13.mediapicker.Image.ImagePicker; 16 | 17 | import java.util.List; 18 | 19 | import static android.app.Activity.RESULT_OK; 20 | 21 | 22 | /** 23 | * Created by alhazmy13 on 3/13/17. 24 | */ 25 | 26 | public class ImageFragment extends Fragment { 27 | private ImageView imageView; 28 | private TextView path; 29 | 30 | private static final String TAG = "MainActivity"; 31 | private List mPath; 32 | 33 | 34 | @Override 35 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, 36 | Bundle savedInstanceState) { 37 | View view = inflater.inflate(R.layout.image_layout, container, false); 38 | 39 | // Find our View instances 40 | imageView = view.findViewById(R.id.iv_image); 41 | path = view.findViewById(R.id.tv_path); 42 | view.findViewById(R.id.bt_pick).setOnClickListener(new View.OnClickListener() { 43 | @Override 44 | public void onClick(View v) { 45 | pickImage(); 46 | } 47 | }); 48 | return view; 49 | } 50 | 51 | 52 | private void pickImage() { 53 | new ImagePicker.Builder(getActivity()) 54 | .mode(ImagePicker.Mode.CAMERA_AND_GALLERY) 55 | .allowMultipleImages(true) 56 | .compressLevel(ImagePicker.ComperesLevel.MEDIUM) 57 | .directory(ImagePicker.Directory.DEFAULT) 58 | .extension(ImagePicker.Extension.PNG) 59 | .allowOnlineImages(true) 60 | .scale(600, 600) 61 | .allowMultipleImages(true) 62 | .enableDebuggingMode(true) 63 | .build(); 64 | } 65 | 66 | @Override 67 | public void onActivityResult(int requestCode, int resultCode, Intent data) { 68 | super.onActivityResult(requestCode, resultCode, data); 69 | Log.d(TAG, "onActivityResult() called with: requestCode = [" + requestCode + "], resultCode = [" + resultCode + "], data = [" + data + "]"); 70 | if (requestCode == ImagePicker.IMAGE_PICKER_REQUEST_CODE && resultCode == RESULT_OK) { 71 | mPath = data.getStringArrayListExtra(ImagePicker.EXTRA_IMAGE_PATH); 72 | Log.d(TAG, "onActivityResult: "); 73 | loadImage(); 74 | } 75 | } 76 | 77 | private void loadImage() { 78 | Log.d(TAG, "loadImage: " + mPath.size()); 79 | if (mPath != null && mPath.size() > 0) { 80 | path.setText(mPath.get(0)); 81 | imageView.setImageBitmap(BitmapFactory.decodeFile(mPath.get(0))); 82 | } 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /app/src/main/java/net/alhazmy13/mediapickerexample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package net.alhazmy13.mediapickerexample; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.annotation.VisibleForTesting; 6 | import android.support.design.widget.TabLayout; 7 | import android.support.v4.app.Fragment; 8 | import android.support.v4.app.FragmentManager; 9 | import android.support.v4.app.FragmentStatePagerAdapter; 10 | import android.support.v4.view.PagerAdapter; 11 | import android.support.v4.view.ViewPager; 12 | import android.support.v7.app.AppCompatActivity; 13 | 14 | public class MainActivity extends AppCompatActivity { 15 | private Fragment videoFragment = new VideoFragment(); 16 | private Fragment imageFragment = new ImageFragment(); 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_main); 22 | 23 | ViewPager mPager = findViewById(R.id.pager); 24 | PagerAdapter mPagerAdapter = new PickerAdapter(getSupportFragmentManager()); 25 | mPager.setAdapter(mPagerAdapter); 26 | TabLayout tabLayout = findViewById(R.id.tabs); 27 | tabLayout.setupWithViewPager(mPager); 28 | for (int i = 0; i < mPagerAdapter.getCount(); i++) 29 | tabLayout.getTabAt(i).setText(mPagerAdapter.getPageTitle(i)); 30 | } 31 | 32 | private class PickerAdapter extends FragmentStatePagerAdapter { 33 | private static final int NUM_PAGES = 2; 34 | 35 | 36 | PickerAdapter(FragmentManager fm) { 37 | super(fm); 38 | } 39 | 40 | @Override 41 | public int getCount() { 42 | return NUM_PAGES; 43 | } 44 | 45 | @VisibleForTesting 46 | @Override 47 | public Fragment getItem(int position) { 48 | switch (position) { 49 | case 0: 50 | return videoFragment; 51 | default: 52 | return imageFragment; 53 | } 54 | } 55 | 56 | @VisibleForTesting 57 | public String getPageTitle(int position) { 58 | switch (position) { 59 | case 0: 60 | return getString(R.string.tab_title_video); 61 | default: 62 | return getString(R.string.tab_title_image); 63 | } 64 | } 65 | } 66 | 67 | @Override 68 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 69 | super.onActivityResult(requestCode, resultCode, data); 70 | // 71 | videoFragment.onActivityResult(requestCode, resultCode, data); 72 | imageFragment.onActivityResult(requestCode, resultCode, data); 73 | } 74 | } -------------------------------------------------------------------------------- /app/src/main/java/net/alhazmy13/mediapickerexample/VideoFragment.java: -------------------------------------------------------------------------------- 1 | package net.alhazmy13.mediapickerexample; 2 | 3 | import android.content.Intent; 4 | import android.net.Uri; 5 | import android.os.Bundle; 6 | import android.support.annotation.NonNull; 7 | import android.support.v4.app.Fragment; 8 | import android.util.Log; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.MediaController; 13 | import android.widget.TextView; 14 | import android.widget.VideoView; 15 | 16 | import net.alhazmy13.mediapicker.Video.VideoPicker; 17 | 18 | import java.util.List; 19 | 20 | import static android.app.Activity.RESULT_OK; 21 | 22 | /** 23 | * Created by alhazmy13 on 3/13/17. 24 | */ 25 | 26 | public class VideoFragment extends Fragment { 27 | private VideoView videoView; 28 | private TextView path; 29 | 30 | private static final String TAG = "MainActivity"; 31 | private List mPath; 32 | 33 | 34 | @Override 35 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, 36 | Bundle savedInstanceState) { 37 | View view = inflater.inflate(R.layout.video_layout, container, false); 38 | init(view); 39 | 40 | return view; 41 | } 42 | 43 | private void init(View view) { 44 | // Find our View instances 45 | videoView = view.findViewById(R.id.iv_video); 46 | MediaController mediaController = new MediaController(getActivity()); 47 | mediaController.setAnchorView(videoView); 48 | videoView.setMediaController(mediaController); 49 | path = view.findViewById(R.id.tv_path); 50 | view.findViewById(R.id.bt_pick).setOnClickListener(new View.OnClickListener() { 51 | @Override 52 | public void onClick(View v) { 53 | pickVideo(); 54 | } 55 | }); 56 | } 57 | 58 | 59 | private void pickVideo() { 60 | new VideoPicker.Builder(getActivity()) 61 | .mode(VideoPicker.Mode.CAMERA_AND_GALLERY) 62 | .directory(VideoPicker.Directory.DEFAULT) 63 | .extension(VideoPicker.Extension.MP4) 64 | .enableDebuggingMode(true) 65 | .build(); 66 | } 67 | 68 | // 69 | @Override 70 | public void onActivityResult(int requestCode, int resultCode, Intent data) { 71 | super.onActivityResult(requestCode, resultCode, data); 72 | Log.d(TAG, "onActivityResult() called with: requestCode = [" + requestCode + "], resultCode = [" + resultCode + "], data = [" + data + "]"); 73 | if (requestCode == VideoPicker.VIDEO_PICKER_REQUEST_CODE && resultCode == RESULT_OK) { 74 | mPath = data.getStringArrayListExtra(VideoPicker.EXTRA_VIDEO_PATH); 75 | loadVideo(); 76 | } 77 | } 78 | 79 | private void loadVideo() { 80 | if (mPath != null && mPath.size() > 0) { 81 | path.setText(mPath.get(0)); 82 | videoView.setVideoURI(Uri.parse(mPath.get(0))); 83 | videoView.start(); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/image_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 13 | 17 | 18 |