I want to upload video selecting from gallery.
I am using Intent to select video from device:
Intent intent = new Intent();
intent.setType("video/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Video"), PICK_VIDEO_REQUEST);
after that:
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == REQUEST_TAKE_GALLERY_VIDEO) {
Uri filePath = data.getData();
try {
String[] projection = {MediaStore.Video.Media.DATA};
Cursor cursor = getContentResolver().query(filePath, projection, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(projection[0]);
String videoPath = cursor.getString(columnIndex);
} catch (Exception e) {
Log.e("error", e.getMessage());
}
}
}
}
but when i am getting path in onActivityResult() it is returning null. I came to know that there is a change in nougat, but can't find any solution.
My code is working in all versions of android except nougat.
please anybody help.