Thursday 15 April 2010

Android Intent ACTION_IMAGE_CAPTURE -



Android Intent ACTION_IMAGE_CAPTURE -

i have simple android app tries take image , send server http post multipart data. problem the behavior of androids intent different on phones. when run

intent intent = new intent(android.provider.mediastore.action_image_capture); startactivityforresult(intent, 0);

on htc 1 (android 4.1.1) , sony xperia z1 (android 4.4.4), stores image in gallery , calls 1 below works:

data.getdata().getpath();

(data instance of intent), whereas when run same code on lg nexus 5 (android 4.4.4), image not stored, ,

data.getdata();

returns null.

what need way store image (temporally), can transfer server.

looks there bug in recent android stock camera, please see issue report on android. according bug, data field returned photographic camera intent come null in default behavior. (mediastore.extra_output not used).

to guarantee image, allocate file , pass uri in photographic camera intent extras mediastore.extra_output

the best practice in allocating temporary image file ensure underlying media mounted, see this sample code snippet on android developer site. on successful completion of photographic camera intent, utilize file uri allocated...do not utilize getdata (could null).

android android-intent bitmap

No comments:

Post a Comment