I need to send byte[] data from Activity1 to Activity2 in order to write data("FileOutputStream.write(data)") to a jpg file. My .jpg file can exceed 1 mb.
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)); for this:
ImageSizeMyApp: 446367 (this size is sent to the next activity, and everything is fine)
ImageSizeMyApp: 577368 (this size closes my camera and does not send the next operation)
So 500kb is the size limit for Intent. Is there any other stable method for sending my byte[] larger than 500 kB in between?
Any links or tips are appreciated. Thank you in advance!
Update:
Can I create another class to store this byte [] array? Or is it better to use a static variable?
source share