Android camera photo comes back null

后端 未结 2 1092
悲&欢浪女
悲&欢浪女 2020-12-21 23:29

In my android app I employ a camera activity which sometimes works and sometimes doesn\'t. About 30% of the time the uri set up to store the photo comes back with a null va

2条回答
  •  爱一瞬间的悲伤
    2020-12-22 00:02

    Can anyone explain why this could happen

    ACTION_IMAGE_CAPTURE does not return a Uri, according to the documentation. data.getData(), in your code, should always be null. If it is not null, what that Uri means is undocumented.

    how to resolve it?

    You already know what the Uri is. You put it in EXTRA_OUTPUT. Use that.

    I didn't use to have this problem.

    Yes, you did. There are thousands of Android device models. These ship with dozens, if not hundreds, of camera applications built in. There are dozens, if not hundreds, of additional ACTION_IMAGE_CAPTURE-supporting apps available for download, from places like the Play Store. None of them have to return a Uri, since the documentation does not say that they have to return a Uri (and, even then, there are bugs in camera apps).

提交回复
热议问题