方法1:
在您的第一活動
轉換的ImageView爲位圖
imageView.buildDrawingCache();
Bitmap bitmap = imageView.getDrawingCache();
Intent intent = new Intent(this, NewActivity.class);
intent.putExtra("BitmapImage", bitmap);
在第二活動
Bitmap bitmap = (Bitmap) intent.getParcelableExtra("BitmapImage");
然後在ImageView的顯示位圖。從捆綁
Intent intent = new Intent(this, NextActivity.class);
intent.putExtra("picture", byteArray);
startActivity(intent);
中獲取字節數組轉換成位圖 - :
方法2:
轉換位圖的字節數組: -
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
通行證字節數組意圖圖片: -
Bundle extras = getIntent().getExtras();
byte[] byteArray = extras.getByteArray("picture");
Bitmap bmp = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
ImageView image = (ImageView) findViewById(R.id.imageView1);
image.setImageBitmap(bmp);
來源
2017-01-04 12:07:13
Sjd
只是通過圖片的名字作爲一個字符串 –
參考HTTP:// stackoverflow.com/questions/2091465/how-do-i-pass-data-between-activiti es-on-android – sasikumar