I need to send byte[] data
from Activity1
to Activity2
, in order to writedata("FileOutputStream.write(data)")
in a jpg file. My final .jpg file could exceed 1mb.
Activity1:
public void onPictureTaken(byte[] data, Camera camera) {
Log.w("ImageSizeMyApp", String.valueOf(data.length));
mCamera.startPreview();
Intent shareWindow = new Intent(Activity1.this, Activity2.class);
shareWindow.putExtra("photo",data);
startActivity(shareWindow);
closeCamera();
Log.w("CameraActivity:", "onPictureTaken");
}
In Activity2:
Bundle extras = getIntent().getExtras();
data = extras.getByteArray("photo");
I use Log.w("ImageSizeMyApp", String.valueOf(data.length));
to get this:
ImageSizeMyApp﹕ 446367 (this size sends to the next activity, and everything is good)
ImageSizeMyApp﹕ 577368 (this size closes my camera, and does not send to the next activity)
So 500kb is the limit dimension for Intent. Is there any other stable method to send my byte[]
larger than 500kb between activities?
Any reference or advice is welcome. Thanks in advance!
Update:
Could I make another class to store that byte[] array? Or is it better to use a static variable?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…