I am working on android application in which I am selecting Video files from gallery. Everything is fine but I want to show video files there which are below 5MB
, I don't want to show all Videos exceeding 5MB
. My code to show Video gallery and onActivityResult
is given below:
public void takeVideoFromGallery(){
Intent intent = new Intent();
intent.setType("video/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Video"),REQUEST_TAKE_GALLERY_VIDEO);
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == this.RESULT_OK) {
switch (requestCode) {
case REQUEST_TAKE_GALLERY_VIDEO:
if (resultCode == RESULT_OK) {
showVideoGallery(data);
Toast.makeText(this, "Video saved to:\n" +data.getData(), Toast.LENGTH_LONG).show();
} else if (resultCode == RESULT_CANCELED) {
Toast.makeText(this, "Video recording cancelled.",Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "Failed to record video",Toast.LENGTH_LONG).show();
}
break;
}