How to save image to file?

I am trying to use a standard Intent that will take a snapshot and then allow approval or return. Then I want to save the image to a file.

In this intent, I use:

Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );

startActivityForResult( intent, 22 );

The documentation says:

The caller may pass an extra EXTRA_OUTPUT to control where this image will be recorded. If EXTRA_OUTPUT is missing, then the small image is returned as a Bitmap object in the additional field. If EXTRA_OUTPUT is present, then the full-sized image will be recorded in the Uri value EXTRA_OUTPUT.

I do not pass additional output, I hope to get the Bitmap object in the optional Intent field passed to onActivityResult()(for this request). So where / how do you retrieve it? Intent has getExtras(), but returns a Bundle, and Bundle wants the key string to give you something back.

What do you call in intent to extract a bitmap?

+3
source share
2 answers

Try calling getExtras().get("data")and returning the result in Bitmap.

See here for an example .

+3
source

In the corresponding note, if you have the action "crop" after shooting with intent.putExtra("crop", "true"), you will get a clipped URI from getExtras().get("action").

, , , .

: Android android LolCat.

0

Source: https://habr.com/ru/post/1737073/


All Articles