보내는 Activity:
Bitmap -> ByteArray 로 전환 후 Intent의 Extra로 넣어서 전달.
Bitmap bitmap = snapshot; ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); byte[] byteArray = stream.toByteArray(); Intent intent = new Intent(Activity.this, AnotherActivity.class); intent.putExtra("image",byteArray); startActivity(intent); |
받는 Activity:
ByteArray -> Bitmap으로 전환.
byte[] arr = getIntent().getByteArrayExtra("image"); Bitmap bm = BitmapFactory.decodeByteArray(arr, 0, arr.length); |
보낼때 :
BitmapDrawable d = (BitmapDrawable)(ImageView)view.findViewById(R.id.imageView1)).getDrawable();
Bitmap b = d.getBitmap();
imgview.setImageBitmap(b);
intent.putExtra("bm", (Bitmap)b);
받는 Activity :
Bitmap bm = (Bitmap)in.getExtras().get("bm");
imgview.setImageBitmap(bm);
또는
Bitmap bm = (Bitmap)in.getParcelableExtra("bm");
imgview.setImageBitmap(bm);
주의
byteArray 사이즈는 40k까지만 전송 가능. 그 이상 크기의 배열을 전송할 경우에는
!!! FAILED BINDER TRANSACTION !!!
오류 뜸.
출저 : http://smile8916.tistory.com/72
'Android' 카테고리의 다른 글
액티비티 전체를 덮는 네비게이션 드로어 만들기 (0) | 2015.08.19 |
---|---|
안드로이드 머터리얼 Style 설정 (0) | 2015.08.19 |
머터리얼 디자인 적용하기 (0) | 2015.08.04 |
안드로이드 메모리 관리 (0) | 2015.07.23 |
안드로이드 스튜디오에서 라이브러리 임포트하기 (0) | 2015.06.19 |