Android camera intent resultcode sometimes wrong / Sony Experia Z -


in android app capture images camera intent. have listview different items, when clicking on item activity shown user can take picture. below code camera intent:

    cameraintent = new intent(mediastore.action_image_capture);      cameraintent.putextra(mediastore.extra_screen_orientation,             activityinfo.screen_orientation_portrait);      startactivityforresult(cameraintent, camera_key); 

and here code onactivityresult():

@override public void onactivityresult(int requestcode, int resultcode, intent data) {      if (resultcode == activity.result_ok) {          if (requestcode == camera_key) {              calldialog();          } else {                      }      } else if (resultcode == activity.result_canceled) {          } } 

with couple of smartphones works perfectly. sony experia z resultcode 0 instaed of -1 successfull taken picture. tested logcat. calling activity paused, , when getting camera intent seems resultcode lost. maybe because calling activity in pause-state , onresume called after onactivityresult-method? (see in logcat) how guaranteed right resultcode camera intent?

is lifecycle-issue? because seems every second picture 1 row item (after updating data) happening?

so don´t know if 1 , correct answer, fixed issue. changed code following , works. seems devices need explicit name filename etc.

            filename = getcurrenttime() + "tmp.jpg";             contentvalues values = new contentvalues();             values.put(mediastore.images.media.title, filename);             mimagecaptureuri = getcontentresolver().insert(                     mediastore.images.media.external_content_uri, values);              intent cameraintent = new intent(                     mediastore.action_image_capture);             cameraintent                     .putextra(mediastore.extra_output, mimagecaptureuri);              cameraintent.putextra(mediastore.extra_screen_orientation,                     activityinfo.screen_orientation_portrait);              startactivityforresult(cameraintent, camera_key); 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -