0

I am using the following notification

 NotificationCompat.Builder builder = new NotificationCompat.Builder( getApplicationContext(), default_notification_channel_id ) ;
        String currentDate = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()).format(new Date());
        builder.setContentTitle( "test! "+currentDate ) ;
        builder.setContentText("test text!") ;

      PendingIntent pendingIntent =
             PendingIntent.getActivity(getApplicationContext(), 10, new Intent(getApplicationContext(), MainActivity.class),0);
        builder.setContentIntent(pendingIntent);
        builder.setDefaults(Notification.DEFAULT_SOUND);

        builder.setAutoCancel( true ) ;
        Drawable drawable= ContextCompat.getDrawable(this,R.drawable.notificationstoreicon);

        Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap();

       builder.setLargeIcon(bitmap); //bitmap dimensions 512x512 size 768kb xxxhdpi in drawable folder
        builder.setSmallIcon(R.drawable.transparenticon) ;
        builder.setChannelId( NOTIFICATION_CHANNEL_ID ) ;

This specific line builder.setLargeIcon(bitmap); is causing the app to crash on emulator. Its working on my tablet android device.

How should i use the bitmap to overcome the crash on the emulator?

stefanosn
  • 2,878
  • 9
  • 43
  • 68
  • 1
    Utilizing a library to load images into imageviews can give you options to resize the images. Something like Picasso https://square.github.io/picasso/. The answer to your question though is that you should resize the bitmap so that it doesn't overload and crash your image view. – Nathan Walsh Oct 16 '20 at 16:05
  • 1
    https://stackoverflow.com/questions/4837715/how-to-resize-a-bitmap-in-android – Nathan Walsh Oct 16 '20 at 16:07
  • Thats what i did lower the file size by resizing the image thanks. – stefanosn Oct 16 '20 at 17:35

0 Answers0