 <pre><code>// Global Declaration Intent intent; String imageFileName,videoFileName; Uri uri; private void clickPhotoFromCamera() { intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); imageFileName = "JPEG_" + timeStamp + ".jpg"; File imageStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), imageFileName); uri = Uri.fromFile(imageStorageDir); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); startActivityForResult(intent, 1); } private void captureVideoFromCamera() { intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); videoFileName = "VID_" + timeStamp + ".mp4"; File videoStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), videoFileName); uri = Uri.fromFile(videoStorageDir); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); startActivityForResult(intent, 2); } private void uploadMediaFromGallery() { intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/* video/*"); startActivityForResult(intent, 3); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { if (requestCode == 1) { imagePath = uri.getPath(); // Do whatever you want with image path... } else if (requestCode == 2) { videoPath = uri.getPath(); // Do whatever you want with Video path... } else { uri = data.getData(); mediaPath = getPath(getApplicationContext(), uri); } } } </code></pre> <p><Br> // For get Image or video from path...</p> <pre><code>File mediaFile = new File(mediaPath); Bitmap bitmap; if (mediaFile.exists()) { if (isImage(mediaPath)) { Bitmap myBitmap = BitmapFactory.decodeFile(mediaFile.getAbsolutePath()); int height = (myBitmap.getHeight() * 512 / myBitmap.getWidth()); Bitmap scale = Bitmap.createScaledBitmap(myBitmap, 512, height, true); int rotate = 0; try { exif = new ExifInterface(mediaFile.getAbsolutePath()); } catch (IOException e) { e.printStackTrace(); } int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED); switch (orientation) { case ExifInterface.ORIENTATION_NORMAL: rotate = 0; break; case ExifInterface.ORIENTATION_ROTATE_270: rotate = 270; break; case ExifInterface.ORIENTATION_ROTATE_180: rotate = 180; break; case ExifInterface.ORIENTATION_ROTATE_90: rotate = 90; break; } Matrix matrix = new Matrix(); matrix.postRotate(rotate); Bitmap rotateBitmap = Bitmap.createBitmap(scale, 0, 0, scale.getWidth(), scale.getHeight(), matrix, true); displayImage.setImageBitmap(rotateBitmap); } else { bitmap = ThumbnailUtils.createVideoThumbnail(mediaPath, Thumbnails.MICRO_KIND); displayImage.setImageBitmap(bitmap); } } public static boolean isImage(String str) { boolean temp = false; String[] arr = { ".jpeg", ".jpg", ".png", ".bmp", ".gif" }; for (int i = 0; i &lt; arr.length; i++) { temp = str.endsWith(arr[i]); if (temp) { break; } } return temp; } </code></pre>