我在将byte []数据传递给不同的活动时遇到问题。
这是我到目前为止所做的:
myIntent = new Intent(HomeActivity.this,DrawingActivity.class);
takePictureBtn = (ImageButton) findViewById(R.id.takePictureBtn);
takePictureBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
camera.takePicture(null, null, new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
myIntent.putExtra("pic", data);
}
});
inPreview = true;
startActivity(myIntent);
}
});
在DrawingActivity中,我有以下内容:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.drawing_view);
byte[] picByte = getIntent().getExtras().getByteArray("pic");
Bitmap bm = BitmapFactory.decodeByteArray(picByte, 0, picByte.length);
Drawable background = (Drawable)new BitmapDrawable(bm);
//There is more stuf I do with Drawable in here
}
以下是我收到的错误的屏幕截图: