摩托罗拉在Android 2.2摄像头忽略EXTRA_OUTPUT参数 [英] Motorola Android 2.2 camera ignore EXTRA_OUTPUT parameter
问题描述
我编程开放式摄像机拍摄录像。我用code象下面这样告诉相机把视频文件到指定的位置:
I programatically open camera to take a video. I tell camera to put the video file to a specified place using code like below:
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
File out = new File("/sdcard/camera.mp4");
Uri uri = Uri.fromFile(out);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
startActivityForResult(intent, GlobalUtility.CAMERA_VIDEO);
它运作良好,一部HTC手机。但在我的摩托车以身试法,它只是忽略MediaStore.EXTRA_OUTPUT参数,并把视频的默认位置。
于是我用这个code中的onActivityResult()函数来解决这个问题:
It works well on a HTC phone. But on my moto defy, it just ignore the MediaStore.EXTRA_OUTPUT parameter, and put the video to the default place. So then I use this code in onActivityResult() function to solve the problem:
private String getRealPathFromURI(Uri contentUri) {
String[] proj = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(contentUri, proj, null, null, null);
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
String realPath;
try {
File file = new File("/sdcard/camera.mp4");
if (!file.exists()) {
Uri videoUri = data.getData();
realPath = getRealPathFromURI(videoUri);
}
} catch (Exception ex) {
Uri videoUri = data.getData();
realPath = getRealPathFromURI(videoUri);
}
希望这将帮助一些人。
Hope this will help some others.
推荐答案
我做过这样的,还是没没有发现任何error..so请尝试这你摩托车以身试法这样我就可以知道的现实。
I have done this way and still didn't found any error..so please try this in you "moto defy" so I can know the reality.
以唤出意图:
Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(intent,2323);
在结果上的活动:
Uri contentUri = data.getData();
String[] proj = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
String tmppath = cursor.getString(column_index);
videoView.setVideoPath(path);
这篇关于摩托罗拉在Android 2.2摄像头忽略EXTRA_OUTPUT参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!