2014-07-25 98 views
-5
Bitmap r = imagelist[args.Position].Data; 
      byte[] arr = getByteFromBitmap(r); 
      var activity2 = new Intent(this, typeof(FullScreenImageViewActivity)); 
      activity2.PutExtra("FullImage", arr); 
      StartActivity(activity2); 

我得到correkt字節[]並把它放在意圖。但它永遠不會把我帶到其他活動,所以下面的代碼不會被觸發。傳遞值從一個活動到另一個失敗

byte[] b = Intent.GetByteArrayExtra("FullImage"); 
     Bitmap bitmap = BitmapFactory.DecodeByteArray(b, 0, b.Length); 
     imageView.SetImageBitmap(bitmap); 
+0

請檢查: HTTP:// stackoverflow.com/questions/2459524/how-can-i-pass-a-bitmap-object-from-one-activity-to-another – user3872416

+0

我嘗試過,但不知何故它甚至不啓動其他活動 –

回答

0

首先,你不應該在intent參數中使用「typeof」。
它應該去:
var activity2 = new Intent(this,FullScreenImageViewActivity.class);
秒,你在Bitmap上使用.putExtra,但是試圖在第二個活動中提取一個字節數組。這將不會結束。

0

試試這個代碼.....

傳遞意圖..

byte[] arr = YOURBYTEARRAY; 

Intent intent= new Intent(this, FullScreenImageViewActivity.class); 
intent.PutExtra("FullImage", arr); 
StartActivity(intent); 

至獲取意圖值..

byte[] b = getIntent().getByteArrayExtra("FullImage") 
相關問題