1

I am trying to open the android default video camera from my app, using the following code:

Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(intent, 1);

But on my two phones (Samsung Note 2, and Google Pixel), it opens the image camera instead. I have this permission in my manifest:

<uses-permission android:name="android.permission.CAMERA"/>

Any ideas what causes this issue? I've also requested the permission at runtime.

Userrrrrrrrr
  • 183
  • 3
  • 12
  • [This sample app](https://github.com/commonsguy/cw-omnibus/tree/master/Media/VideoRecordIntent) that uses `ACTION_VIDEO_CAPTURE` works fine on a Pixel. – CommonsWare Nov 15 '16 at 18:13
  • Tried some things from the app but it's still not working. I'm also using the uses-feature thing, but that isn't changing anything – Userrrrrrrrr Nov 15 '16 at 18:21
  • I just copied the code for the intent from the sample app into my app and it still isn't working – Userrrrrrrrr Nov 15 '16 at 18:28
  • I don't know why you keep getting answers involving permissions. You **do not need camera permissions to record a video if you are using a third part app**. The only thing you may need is the WRITE_EXTERNAL permission to actually save the file. – DeeV Nov 15 '16 at 19:16
  • Other than this, I just did the `MediaStore.ACTION_VIDEO_CAPTURE` intent on my HTC M9. It seems to work appropriately. It opened the camcorder. One thing to note is that when using third party apps, you are forced to go with their implementation. They may not simply open up to the camcorder when they capture this Intent. – DeeV Nov 15 '16 at 19:17

3 Answers3

0

Add follow permission CAPTURE_SECURE_VIDEO_OUTPUT and CAPTURE_VIDEO_OUTPUT

-1

You must add next code. Devices have Android 6.0 or later.

if(ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED){
        Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
        startActivityForResult(intent, 1);
    } else {
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 2);
    }

If your the app has the permission for use the STORAGE we open the STORAGE.

If your the app doesn't have permission for use STORAGE, we open system-dialog. Result from the dialog you can see in the onRequestPermissionsResult. (You must override it on your Activity).

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
        @NonNull int[] grantResults) {
    if (requestCode == 2) {
        if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
            startActivityForResult(intent, 1);
        }
    }
}

I think you must extract next lines to the private method.

private void takePhoto() {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    startActivityForResult(intent, 1);
}

For more information see : https://developer.android.com/training/permissions/requesting.html

-1

Android 6.0 and later requieres to ask permissions at run time. Read the official doc here: https://developer.android.com/training/permissions/requesting.html

I hope it helps.

kelmi92
  • 394
  • 2
  • 8