public void showNotification(){ NotificationCompat.Builder builder = new NotificationCompat.Builder (getApplicationContext()); Intent intent = new Intent(getApplicationContext(),ImageActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); builder .setContentIntent(pendingIntent) .setSmallIcon(R.mipmap.ic_launcher) .setLargeIcon(BitmapFactory.decodeFile(getCacheDir() + "/Image-" + 1 + ".jpg")) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setContentTitle("напоминание") .setContentText("Напоминание!"); Notification notification = builder.build(); int NOTIFICATION = 127; nm.notify(NOTIFICATION, notification); } 

LargeImage not initialized, but instead it is SmallIcon . Rather, this line of code does not want to perceive. If you set the picture initially in drawable resources, it turns out fine, but if I need to download it, nothing comes out

  • Are you sure that everything is correct? for example, the path to the image? - Vladyslav Matviienko
  • Yes, I'm sure the path is set correctly, it opens in other parts of the program, perhaps also because notification is in the service, although I don’t think this is a big problem - user199598
  • one
    And in LogCat there is something at the moment of displaying the notification "eh? - Vladyslav Matviienko
  • Thanks a lot and the file was read while it was loaded, wait () fixed the problem. - user199598
  • @ user199598, if you have found a solution to the problem, you can write about it in the answer. - Yuriy SPb

1 answer 1

Try this:

 BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; FileInputStream stream1=new FileInputStream(new File(getCacheDir() + "/Image-" + 1 + ".jpg")); Bitmap bm = BitmapFactory.decodeStream(stream1,null,o); stream1.close(); //далее //.setLargeIcon(bm)