android select video samsung stackoverflow

Solutions on MaxInterview for android select video samsung stackoverflow by the best coders in the world

showing results for - "android select video samsung stackoverflow"
Alma
03 Jul 2019
1Intent intent = new Intent();
2intent.setType("video/*");
3intent.setAction(Intent.ACTION_GET_CONTENT);
4startActivityForResult(Intent.createChooser(intent,"Select Video"),REQUEST_TAKE_GALLERY_VIDEO);
5
6public void onActivityResult(int requestCode, int resultCode, Intent data) {
7        if (resultCode == RESULT_OK) {
8            if (requestCode == REQUEST_TAKE_GALLERY_VIDEO) {
9                Uri selectedImageUri = data.getData();
10
11                // OI FILE Manager
12                filemanagerstring = selectedImageUri.getPath();
13
14                // MEDIA GALLERY
15                selectedImagePath = getPath(selectedImageUri);
16                if (selectedImagePath != null) {
17
18                    Intent intent = new Intent(HomeActivity.this,
19                            VideoplayAvtivity.class);
20                    intent.putExtra("path", selectedImagePath);
21                    startActivity(intent);
22                }
23            }
24        }
25    }
26
27    // UPDATED!
28    public String getPath(Uri uri) {
29        String[] projection = { MediaStore.Video.Media.DATA };
30        Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
31        if (cursor != null) {
32            // HERE YOU WILL GET A NULLPOINTER IF CURSOR IS NULL
33            // THIS CAN BE, IF YOU USED OI FILE MANAGER FOR PICKING THE MEDIA
34            int column_index = cursor
35                    .getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
36            cursor.moveToFirst();
37            return cursor.getString(column_index);
38        } else
39            return null;
40    }