开发者

Android Video Recording ,Camera Intent

I use following Intents for recording video and taking pictures, but in Motorola Droid 2.2 the camera Intent save option fails, ie nothing get saved, and the camcoder Intent cancel crashes 开发者_Go百科my application.

In both Intent I explicitly passing the file and after it return result "ok" I use the file, ie when user press the save/insert options in the intent: SAVE in camcoder no problem, only cancel casues crash in camcorder.

Camera

 Intent intent2 = new Intent("android.media.action.IMAGE_CAPTURE");
 imgUri = Uri.fromFile(photofile);
 intent2.putExtra(MediaStore.EXTRA_OUTPUT, imgUri);
 startActivityForResult(intent2, 1);

Camcoder

 Intent i = new Intent("android.media.action.VIDEO_CAPTURE");
 i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(videofile));
 i.putExtra(android.provider.MediaStore.EXTRA_VIDEO_QUALITY, 0);
 i.putExtra("android.intent.extra.durationLimit", 60);
 startActivityForResult(i, 2);

NB: The Recorded Video can't be played with HTC ERIS


If you can't avoid using android.provider.MediaStore.EXTRA_OUTPUT try to prepare URI via content provider like that

context.getContentResolver().insert(android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI, contentValues);

To to so you should prepare correct content values first (setup MediaColumns.DISPLAY_NAME, MediaColumns.MIME_TYPE and so on).

But the best way is just to not specify you own URI and user URI that system will give for your video.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜