How to pass an image from one activity to another using Intents in Xamarin Android? -


i'm web developer started exploring android development world using xamarin i'm struggling find way task.

my image located in drawables-hdpi.

in main activity, i've set header image on imageview using tutorial http://developer.xamarin.com/recipes/android/resources/general/load_large_bitmaps_efficiently/

now, created activity when user clicks on header image, second activity comes action , allows user pan , zoom around image.

i need second activity dynamically receive image first activity.

here's i've tried no success. i'm using same "load images efficiently" code in second activity well, don't think matters anyway.

  // set image   bitmapfactory.options options = await getbitmapoptionsofimage();    bitmap bitmaptodisplay = await loadscaleddownbitmapfordisplayasync (resources, options, 400, 400);   headerimage.setimagebitmap(bitmaptodisplay);    headerimage.click += (object sender, eventargs e) => {      var intent = new intent(this, typeof(imagescaleactivity));      headerimage.builddrawingcache();     bitmap image = headerimage.getdrawingcache(true);      bundle extras = new bundle();     extras.putparcelable("imagebitmap", image);     intent.putextras(extras);      // todo: dynamically image name , send next activity      startactivity(intent);    }; 

that code isn't working, i'm not getting errors when tap on header image, nothing shows in second activity, image not being sent.

here's code in second activity.

  // set image   bitmapfactory.options options = await getbitmapoptionsofimage();    bitmap bitmaptodisplay = await loadscaleddownbitmapfordisplayasync (resources, options, 400, 400);   //expandedimage.setimagebitmap(bitmaptodisplay);    bundle extras = intent.extras;   bitmap bmp = (bitmap) extras.getparcelable("imagebitmap");    expandedimage.setimagebitmap(bmp); 

i don't think i'm going proper way , don't see why seems difficult do!

if have image in drawable there no need send second activity. set drawable in second activity this.

imageview imgview=(imageview) findviewbyid(r.id.imgview); drawable  drawable  = getresources().getdrawable(r.drawable.img); imgview.setimagedrawable(drawable); 

Comments