android - Difficulties with intents and several activities -
i have main activity launch application. in main activity have imageview
string of path selected thumbnails gridview
in sec activity via intent.
this perhaps sounds unusual , more naturally launch sec activity first gridview
, requirement task.
so i'm struggling difficulties how deal string imageid
expects intent sec activity? guess have set button open sec activity , gridview
menu button, ideas how deal intent thing? appreciate help!
code in main activity:
string imageid = i.getextras().getstring("image"); imageview imageview = (imageview) findviewbyid(r.id.full_image_view); bitmap bitmap =bitmapfactory.decodefile(imageid); imageview.setimagebitmap(bitmap);
open sec activity using startactivityforresult
, like:
to start sec activity:
intent = new intent(this, secondactivity.class); startactivityforresult(i, 1);
then handle returned result:
@override protected void onactivityresult(int requestcode, int resultcode, intent data) { if(resultcode == activity.result_ok) { string imageid = data.getextras().getstring("image"); imageview imageview = (imageview) findviewbyid(r.id.full_image_view); bitmap bitmap =bitmapfactory.decodefile(imageid); imageview.setimagebitmap(bitmap); } }
in sec actitivty, when thumbnail selected:
intent intent = new intent(); intent.putextra("image", path); setresult(result_ok, intent); finish();
check http://stackoverflow.com/a/10407371/1434631
android android-intent
No comments:
Post a Comment