Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 512
Bytecode Avatar asked Dec 09 '10 06:12

Bytecode


People also ask

What is the permission for using camera?

Camera Permission - Your application must request permission to use a device camera. Note: If you are using the camera by invoking an existing camera app, your application does not need to request this permission. For a list of camera features, see the manifest Features Reference.

How do I record video on my Android camera?

For most Android devices, you can find the video recorder under the camera app. Once you're in your camera, scroll along the bottom of your screen to find the Video tab. From here, you can press the record button on your screen to start the video and then press stop to end it.


1 Answers

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.

like image 180
fo2rist Avatar answered Sep 24 '22 11:09

fo2rist