0
@ Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (data.getData()!=null) {
        videoUri = data.getData();


        if (resultCode == RESULT_OK) {
            if (requestCode == REQUEST_VIDEO) {
                Toast.makeText(this, data.getData().toString(), Toast.LENGTH_LONG).show();

            } else if (requestCode == VIDEO_RECORD_REQUEST) {
                videoUri = data.getData();
                Toast.makeText(this, data.getData().toString(), Toast.LENGTH_LONG).show();
            }
        }
    }
    else
    {
        Toast.makeText(this, "No file", Toast.LENGTH_SHORT).show();
    }

}

I have tried this code it works fine but I also want to get the thumbnail of result video URI.

Shahzeb
  • 41
  • 3
  • Possible duplicate of [Get Video Thumbnail from Uri](https://stackoverflow.com/questions/44109057/get-video-thumbnail-from-uri) – ADM Mar 01 '19 at 16:10

1 Answers1

0

in onActivityResult

String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = context.getContentResolver().query(uri, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();

Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(picturePath, MediaStore.Video.Thumbnails.MICRO_KIND);

check de this official docs

developer.android

Camilo Andres
  • 196
  • 1
  • 12
  • you can use a function like this: public Uri getImageUri(Context inContext, Bitmap inImage) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes); String path = Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null); return Uri.parse(path); } – Camilo Andres Mar 04 '19 at 05:59
  • I don't try with the following lines, but may be it works for you, : String FILENAME = "image.png"; String PATH = "/mnt/sdcard/"+ FILENAME; File f = new File(PATH); Uri yourUri = Uri.fromFile(f); – Camilo Andres Mar 04 '19 at 06:01