Android Camera : data intent returns null

前端 未结 11 1584
不知归路
不知归路 2020-11-22 16:20

I have an android application which contains multiple activities.

In one of them I\'m using a button which will call the device camera :

public void         


        
11条回答
  •  囚心锁ツ
    2020-11-22 17:09

    The default Android camera application returns a non-null intent only when passing back a thumbnail in the returned Intent. If you pass EXTRA_OUTPUT with a URI to write to, it will return a null intent and the picture is in the URI that you passed in.

    You can verify this by looking at the camera app's source code on GitHub:

    • https://github.com/android/platform_packages_apps_camera/blob/gingerbread-release/src/com/android/camera/Camera.java#L1186

      Bundle newExtras = new Bundle();
      if (mCropValue.equals("circle")) {
          newExtras.putString("circleCrop", "true");
      }
      if (mSaveUri != null) {
          newExtras.putParcelable(MediaStore.EXTRA_OUTPUT, mSaveUri);
      } else {
          newExtras.putBoolean("return-data", true);
      }
      

    I would guess that you're either passing in EXTRA_OUTPUT somehow, or the camera app on your phone works differently.

提交回复
热议问题