Skip to content

Instantly share code, notes, and snippets.

@Folyd
Last active October 8, 2015 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Folyd/29df4b75b2fd9ac74b2d to your computer and use it in GitHub Desktop.
Save Folyd/29df4b75b2fd9ac74b2d to your computer and use it in GitHub Desktop.
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);
}
@Override
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);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
filePath = cursor.getString(columnIndex);
cursor.close();
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