java - Android intent selecting image bug -
whenever open gallery, have select image 3 times before loads image on activity.
this code intent
bchange.setontouchlistener(new ontouchlistener(){ public boolean ontouch(view v, motionevent e) { try { intent intent = new intent(intent.action_pick, android.provider.mediastore.images.media.external_content_uri); startactivityforresult(intent, select_photo); } catch (exception e2) { toast.maketext(getapplicationcontext(),e2.getmessage(),toast.length_long).show(); log.e(e2.getclass().getname(), e2.getmessage(), e2); } return false; } });
then here activity result code
@override protected void onactivityresult(int requestcode, int resultcode, intent data){ super.onactivityresult(requestcode, resultcode, data); if (resultcode == result_ok && null != data) { uri selectedimage = data.getdata(); string filemanagerstring = selectedimage.getpath(); string selectedimagepath = data.getdatastring(); dbhelper = new tipdbhelper(this); sqlitedatabase database = dbhelper.getwritabledatabase(); contentvalues updatecvals = new contentvalues(); string selimagepath = getrealpathfromuri(uri.parse(selectedimagepath)); updatecvals.put("setting_value", selimagepath); string whereclause = " setting_name = 'background'"; imageview iv = (imageview) findviewbyid(r.id.catcher); database.update("tblsetting", updatecvals, whereclause, null); try { usesettings(iv); } catch (ioexception e) { system.out.println("error here"); e.printstacktrace(); } database.close(); } }
is there way select once activity loads image immediately?
Comments
Post a Comment