Putting a request into a function and then calling the function using onClick() .
public void openGalleryImage(){ Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent,"Select Image "), SELECT_IMAGE); } public void openGalleryVideo(){ Intent intent = new Intent(); intent.setType("video/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent,"Select vVideo "), SELECT_VIDEO); }
source share