【问题标题】:pass value from one activity to another fails将值从一项活动传递到另一项活动失败
【发布时间】:2014-09-17 07:20:32
【问题描述】:
Bitmap r = imagelist[args.Position].Data;
byte[] arr = getByteFromBitmap(r);
var activity2 = new Intent(this, typeof(FullScreenImageViewActivity));
activity2.PutExtra("FullImage", arr);
StartActivity(activity2);

我得到正确的byte[] 并将其放入意图中。但它永远不会带我去其他活动,所以不会触发下面的代码。

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

【问题讨论】:

标签: android arrays android-intent android-activity bitmap


【解决方案1】:

试试这个代码.....

传递意图..

byte[] arr = YOURBYTEARRAY;

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

获取意图值..

byte[] b = getIntent().getByteArrayExtra("FullImage")

【讨论】:

    【解决方案2】:
    1. 您不应该在意图参数中使用typeof
      它应该去:

      var activity2 = new Intent(this, FullScreenImageViewActivity.class);  
      
    2. 您在位图上使用putExtra,但尝试在第二个活动中提取字节数组。这不会有好的结局。

    【讨论】:

      猜你喜欢
      • 2014-09-19
      • 2012-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多