2013-06-27 1 views
1

서비스에 번들을 보내려고합니다. 이것이 내가 그 부름을 부르는 방식이다.비트 맵을 묶음에 넣고 서비스에 전송하면 IntentService가 호출되지 않습니다.

1) Bundle bundle = new Bundle(); 
2) bundle.putParcelable("bitmap", bmp);  // <--- problem 
3) bundle.putString("type", "SingleImage"); 

4) Intent intent = new Intent(getApplicationContext(),SyncService.class); 
5) intent.putExtra("imageUploadBundle", bundle); 
6) startService(intent); 

내가 line 2이라고 말하면 서비스가 호출됩니다. 그러나 내가 그 라인에 대해 언급하지 않는다면 서비스는 불리지 않는다. 내가 서버에 업로드 할 bitmap to the service을 보내려고합니다. 서비스에 비트 맵을 보내려면 어떻게해야합니까? 이 문제의 원인은 무엇입니까?

+0

이봐, 내가 잘못했다 'android.graphics.BitMap는 Parcelable은 this.' –

+0

을 보낼 수있다 그러나 서비스는 왜 실행되지 않는 이유는 무엇입니까? – Mj1992

+0

내 업데이트 된 답변보기 –

답변

2

이와 같이 행 바이트 배열을 보내보십시오.

ByteArrayOutputStream stream = new ByteArrayOutputStream(); 
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream); 
byte[] byteArray = stream.toByteArray(); 

Bundle bundle = new Bundle(); 
bundle.putByteArray("bitmap", byteArray); 
bundle.putString("type", "SingleImage"); 

Intent intent = new Intent(getApplicationContext(),SyncService.class); 
intent.putExtra("imageUploadBundle", bundle); 
startService(intent); 
+0

thnx this worked – Mj1992