Bytecode
Bytecode

Reputation: 6591

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 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

Upvotes: 6

Views: 5183

Answers (1)

fo2rist
fo2rist

Reputation: 1923

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.

Upvotes: 1

Related Questions