android - Get Image from gallery cause no activity found error in activity resulte -
i try open gallery , let user choose image gallery it's work on android not in tablet (4.2.2) it's work fine friend (4.1.2) it's cause activitynotfound exeption.
the code open gallery:
intent = new intent( intent.action_pick, android.provider.mediastore.images.media.external_content_uri); try { startactivityforresult(i, result_load_image); } catch (activitynotfoundexception e) { e.printstacktrace(); }
and activityresult code:
@override public void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); if (requestcode == result_load_image && resultcode == result_ok && null != data) { uri selectedimage = data.getdata(); string[] filepathcolumn = { mediastore.images.media.data }; cursor cursor = getcontentresolver().query(selectedimage, filepathcolumn, null, null, null); cursor.movetofirst(); int columnindex = cursor.getcolumnindex(filepathcolumn[0]); picturepath = cursor.getstring(columnindex); }
try:-
intent intent = new intent(); intent.settype("image/*"); intent.setaction(intent.action_get_content); startactivityforresult(intent.createchooser(intent, "select picture"), result_load_image);
Comments
Post a Comment