Skip to content

Instantly share code, notes, and snippets.

@shubhamvashisht
Created October 31, 2017 13:15
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 shubhamvashisht/5ca10c687356d959acf3b63a9790d18b to your computer and use it in GitHub Desktop.
Save shubhamvashisht/5ca10c687356d959acf3b63a9790d18b to your computer and use it in GitHub Desktop.
private static final int PICK_VIDEO = 0;
public void pickImage() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("video/*");
startActivityForResult(intent, PICK_VIDEO);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_VIDEO && resultCode == Activity.RESULT_OK) {
if (data == null) {
//Display an error
return;
}
InputStream inputStream = context.getContentResolver().openInputStream(data.getData());
//Now you can do whatever you want with your inpustream, save it as file, upload to a server, decode a bitmap...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment