0

i want to set my camera picture as notification icon

this is my main activity

intent=new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 0);

........................

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode==RESULT_OK){
extras=data.getExtras();
bmp=(Bitmap) extras.get("data");
imageView.setImageBitmap(bmp);
}
}

from my broadcastreceiver i am trying to get the bitmap as

public void onReceive(Context context, Intent intent) {
///////////////////////////................
Bitmap bitmap = (Bitmap) intent.getParcelableExtra("image");
 Notification notification2=new Notification.Builder(context).setTicker(from)
              .setContentTitle(from)
              .setSmallIcon(R.drawable.ic_launcher)
              .setLargeIcon(bitmap)
              .setContentText(message).setContentIntent(contentIntent)
              .addAction(0,"remind",contentIntent).build();

but this is not working i'm getting force stop :(

Ayman
  • 53
  • 9
  • i'm also tried Bitmap bitmap = (Bitmap) intent.getParcelableExtra("image"); Resources res = context.getResources(); int height = (int) res.getDimension(android.R.dimen.notification_large_icon_height); int width = (int) res.getDimension(android.R.dimen.notification_large_icon_width); bitmap = Bitmap.createScaledBitmap(bitmap, width, height, false); ////////////// //........ .setSmallIcon(R.drawable.ic_launcher) .setLargeIcon(bitmap) ////.......... but still getting error – Ayman Aug 11 '14 at 11:49
  • 1
    It would be a lot easier to help you, if you could provide some output of the error message(s). Like the logcat Output. – Fildor Aug 11 '14 at 11:51

1 Answers1

0

If you're getting the error

E/JavaBinder﹕ !!! FAILED BINDER TRANSACTION !!!

it is due to the Bitmap being too big for the Android Binder (which I believe has a limit of 1 MB). You should look into compress the image before trying it to pass it in a Bundle. Take a look at this post: Failed binder transaction when putting an bitmap dynamically in a widget

Community
  • 1
  • 1
murki
  • 879
  • 12
  • 21