I'm getting a NullPointerException when I use ACTION_IMAGE_CAPTURE to take a picture

前端 未结 4 1008
别跟我提以往
别跟我提以往 2020-11-30 14:24

I have a fairly simple app that launches the camera from a menu. The camera launches fine, but when I hit ok after taking a picture I get a NPE on my nexus one:



        
4条回答
  •  春和景丽
    2020-11-30 15:07

    Turns out the stock camera application doesn't send EXTRA_OUTPUT, which is why it's null. However, some camera apps (like the hero) do. Awesome. So the answer is to specify EXTRA_OUTPUT. The nexus one camera app will save the image to that location. Then in onActivityResult() check if the intent is null. If it isn't, use data.getData(), and if it is then use the location specific in EXTRA_OUTPUT via a constant and insert it into the Mediastore. Urgh.

提交回复
热议问题