Android ACTION_IMAGE_CAPTURE Intent

后端 未结 14 2005
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 02:04

We are trying to use the native camera app to let the user take a new picture. It works just fine if we leave out the EXTRA_OUTPUT extra and returns the small B

相关标签:
14条回答
  • 2020-11-22 03:08

    I've been through a number of photo capture strategies, and there always seems to be a case, a platform or certain devices, where some or all of the above strategies will fail in unexpected ways. I was able to find a strategy that uses the URI generation code below which seems to work in most if not all cases.

    mPhotoUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, 
                new ContentValues());
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, mPhotoUri);
    startActivityForResult(intent,CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE_CONTENT_RESOLVER);
    

    To contribute further to the discussion and help out newcomers I've created a sample/test app that shows several different strategies for photo capture implementation. Contributions of other implementations are definitely encouraged to add to the discussion.

    https://github.com/deepwinter/AndroidCameraTester

    0 讨论(0)
  • 2020-11-22 03:09

    I had the same problem where the OK button in camera app did nothing, both on emulator and on nexus one.

    The problem went away after specifying a safe filename that is without white spaces, without special characters, in MediaStore.EXTRA_OUTPUT Also, if you are specifying a file that resides in a directory that has not yet been created, you have to create it first. Camera app doesn't do mkdir for you.

    0 讨论(0)
提交回复
热议问题