Reputation: 13
Hello friends i want to pass bitmap from one activity to another activity. i did it successfully but my problem is that when bitmap is passed to another activity it giving error of FAILED BINDER TRANSACTION. Please friends please help me to resolve this problem. I am using below code to pass image to another activity
Uri selectedImageUri = data.getData();
if(selectedImageUri!=null){
selectedImagePath = getPath(selectedImageUri);
Intent i = new Intent(MainActivity.this, ImageCropperActivity.class);
i.putExtra("mpath", selectedImagePath);
startActivity(i);
and i am getting bitmap like this.
if(imagePath != null){
//Toast.makeText(getApplicationContext(), "image path " +imagePath, Toast.LENGTH_LONG).show();
//imgCrop.setImageBitmap(BitmapFactory.decodeFile(imagePath));
mImageUri = Uri.parse(getIntent().getStringExtra("mpath"));
mFileTemp = new File(getIntent().getStringExtra("mpath"));
}
please friends please help me to resolve this problem.
Upvotes: 0
Views: 2292
Reputation: 2053
try to compress bitmap first and then pass it to next activity
Compress using this
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] bytes = stream.toByteArray();
setresult.putExtra("BMP",bytes);
Uncompress using this code
byte[] bytes = data.getByteArrayExtra("BMP");
Bitmap bmp = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
---Note---
There are some limitations as to how much data a bundle can contain. If your bundle or intent extras are too large you can get FAILED BINDER TRANSACTION error.
hope it helps.
Upvotes: 1