我尝试使用相机意图捕获视频并在 onActivityResult 中获取视频。除某些情况外,它工作正常。
当我在某些手机中长时间拍摄视频时,当我单击保存按钮时,它会返回到相机本身。当我从那里按下后退按钮时,它会返回我的应用程序,但会返回一个新活动。
// Calling camera intent
Intent intent = new Intent(
android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(intent, 1);
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent videoReturnedIntent) {
super.onActivityResult(requestCode, resultCode, videoReturnedIntent);
if (resultCode == RESULT_OK) {
float size = 0;
Uri selectedVideo = videoReturnedIntent.getData();
String[] filePathColumn = { MediaStore.Video.Media.DATA };
Cursor cursor = getContentResolver().query(selectedVideo,
filePathColumn, null, null, null);
if (cursor != null) {
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
filePath = cursor.getString(columnIndex);
cursor.close();
}
}
}