Android Training: Capturing Photo example -


i'm quite new android have been working through examples on google's site - i'm on one: http://developer.android.com/training/camera/index.html

this "simple" example on using camera function on android. there button calls intent. intent displayed below.

private void dispatchtakepictureintent(int actioncode) {      intent takepictureintent = new intent(mediastore.action_image_capture);      switch(actioncode) {     case action_take_photo_b:         file f = null;          try {             f = setupphotofile();             mcurrentphotopath = f.getabsolutepath();             takepictureintent.putextra(mediastore.extra_output, uri.fromfile(f));         } catch (ioexception e) {             e.printstacktrace();             f = null;             mcurrentphotopath = null;         }         break;      default:         break;               } // switch      startactivityforresult(takepictureintent, actioncode); 

as can see above, intent putextra of key mediastore.extra_output. on android's website: http://developer.android.com/reference/android/provider/mediastore.html#extra_output says mediastore.extra_output has constant value of "output".

once user clicks on button, intent called , following extract of onactivityresult method given in code:

@override protected void onactivityresult(int requestcode, int resultcode, intent data) {     switch (requestcode) {      case action_take_photo_s: {         if (resultcode == result_ok) {             handlesmallcameraphoto(data);         }         break;     } // action_take_photo_s 

a method handlesmallcameraphoto(data); called. here code handlesmallcameraphoto.

private void handlesmallcameraphoto(intent intent) {     bundle extras = intent.getextras();     mimagebitmap = (bitmap) extras.get("data");     mimageview.setimagebitmap(mimagebitmap);     mvideouri = null;     mimageview.setvisibility(view.visible);     mvideoview.setvisibility(view.invisible); } 

now in above method, want getextras intent - putextra in under method dispatchtakepictureintent extracting.

we see line here.

mimagebitmap = (bitmap) extras.get("data"); 

isn't "data" inside extras.get("data") key android extract data for? dispatchtakepictureintent, key mediastore.extra_output had constant of "output" not "data", how android know associated "data"?

ok. found answer on android website. answer here: http://developer.android.com/training/camera/photobasics.html#taskpath under heading "get thumbnail"

this special case , android saves thumbnails key called "data" in intent.

the site says: thumbnail image "data" might icon, not lot more.


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -