Skip to main content
deleted 25 characters in body
Source Link
Kaushik
  • 6.2k
  • 5
  • 41
  • 56

#wrong

1). Bitmap quality is high.

2). you are not using try catch.

Suggestions

1). reduce the quality of bitmap to 45-50.

2). use try catch block to prevent your app from crash.

#Solution // sender activity

try{ Intent _intent = new Intent(this, newscreen.class); Bitmap _bitmap; // your bitmap ByteArrayOutputStream _bs = new ByteArrayOutputStream(); _bitmap.compress(Bitmap.CompressFormat.PNG, 50, _bs); i.putExtra("byteArray", _bs.toByteArray()); startActivity(i); }catch(Exception e){ } 

#receiver activity

try{ if(getIntent().hasExtra("byteArray")) { ImageView _imv= new ImageView(this); Bitmap _bitmap = BitmapFactory.decodeByteArray( getIntent().getByteArrayExtra("byteArray"),0,getIntent().getByteArrayExtra("byteArray").length); _imv.setImageBitmap(_bitmap); } }catch(Exception e){ } 

#wrong

1). Bitmap quality is high.

2). you are not using try catch.

Suggestions

1). reduce the quality of bitmap to 45-50.

2). use try catch block to prevent your app from crash.

#Solution // sender activity

try{ Intent _intent = new Intent(this, newscreen.class); Bitmap _bitmap; // your bitmap ByteArrayOutputStream _bs = new ByteArrayOutputStream(); _bitmap.compress(Bitmap.CompressFormat.PNG, 50, _bs); i.putExtra("byteArray", _bs.toByteArray()); startActivity(i); }catch(Exception e){ } 

#receiver activity

try{ if(getIntent().hasExtra("byteArray")) { ImageView _imv= new ImageView(this); Bitmap _bitmap = BitmapFactory.decodeByteArray( getIntent().getByteArrayExtra("byteArray"),0,getIntent().getByteArrayExtra("byteArray").length); _imv.setImageBitmap(_bitmap); } }catch(Exception e){ } 

#wrong

1). Bitmap quality is high.

2). you are not using try catch.

Suggestions

1). reduce the quality of bitmap to 45-50.

2). use try catch block to prevent your app from crash.

#Solution // sender activity

try{ Intent _intent = new Intent(this, newscreen.class); Bitmap _bitmap; // your bitmap ByteArrayOutputStream _bs = new ByteArrayOutputStream(); _bitmap.compress(Bitmap.CompressFormat.PNG, 50, _bs); i.putExtra("byteArray", _bs.toByteArray()); startActivity(i); }catch(Exception e){ } 

#receiver activity

try{ if(getIntent().hasExtra("byteArray")) { ImageView _imv= new ImageView(this); Bitmap _bitmap = BitmapFactory.decodeByteArray(getIntent().getByteArrayExtra("byteArray"),0,getIntent().getByteArrayExtra("byteArray").length); _imv.setImageBitmap(_bitmap); } }catch(Exception e){ } 
Source Link
Pankaj Arora
  • 10.3k
  • 3
  • 39
  • 60

#wrong

1). Bitmap quality is high.

2). you are not using try catch.

Suggestions

1). reduce the quality of bitmap to 45-50.

2). use try catch block to prevent your app from crash.

#Solution // sender activity

try{ Intent _intent = new Intent(this, newscreen.class); Bitmap _bitmap; // your bitmap ByteArrayOutputStream _bs = new ByteArrayOutputStream(); _bitmap.compress(Bitmap.CompressFormat.PNG, 50, _bs); i.putExtra("byteArray", _bs.toByteArray()); startActivity(i); }catch(Exception e){ } 

#receiver activity

try{ if(getIntent().hasExtra("byteArray")) { ImageView _imv= new ImageView(this); Bitmap _bitmap = BitmapFactory.decodeByteArray( getIntent().getByteArrayExtra("byteArray"),0,getIntent().getByteArrayExtra("byteArray").length); _imv.setImageBitmap(_bitmap); } }catch(Exception e){ }