Last active
October 8, 2015 08:32
-
-
Save Folyd/29df4b75b2fd9ac74b2d to your computer and use it in GitHub Desktop.
A video picker activity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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