Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A video picker activity
public class VideoPickerActivity extends Activity{
private final int REQUEST_PICK_VIDEO = 1;
public void onVideoPickClick(View view) {
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Video.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, REQUEST_PICK_VIDEO);
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK && requestCode == REQUEST_PICK_VIDEO) {
Uri uri = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(
uri, filePathColumn, null, null, null);
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
filePath = cursor.getString(columnIndex);
Log.d("uri", "uri:" + uri.toString() + " file path:" + filePath);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment