So I\'m trying to use the built in camera activity to record a video using the below code:
Intent videoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTUR
Actually, I found in some case MediaStore.EXTRA_OUTPUT
doesn't work properly,
SO the other trick way is, store your captured video file in onActivityResult()
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if (resultCode == RESULT_OK)
{
try {
AssetFileDescriptor videoAsset = getContentResolver().openAssetFileDescriptor(intent.getData(), "r");
FileInputStream fis = videoAsset.createInputStream();
File videoFile = new File(Environment.getExternalStorageDirectory(),"<VideoFileName>.mp4");
FileOutputStream fos = new FileOutputStream(videoFile);
byte[] buffer = new byte[1024];
int length;
while ((length = fis.read(buffer)) > 0) {
fos.write(buffer, 0, length);
}
fis.close();
fos.close();
} catch (IOException e) {
// TODO: handle error
}
}
}
Try the above code and let me know about your success.