Notification image never displays in Android



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















If suppose I create Notification icons by uploading a png image using Image Asset tool from Android Studio by choosing type as notification would it generate all required icons with the dimensions as needed by notification icon spec? if Yes, then there should not be any problem displaying this icon in the notification bar, isn't it? hmm it doesn't in my case but rather it shows the default App icon no matter what. Below is my code. Any guess why its failing, perhaps this is just a cosmetic issue through.



 NotificationManager mNotificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)
NotificationChannel channel = new NotificationChannel("VEDRISE",
"Vedic Notifications",
NotificationManager.IMPORTANCE_DEFAULT);
channel.setDescription("Will display daily Panchang notificatons");
mNotificationManager.createNotificationChannel(channel);

Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
// URL url = new //URL("https://66.media.tumblr.com/ec76b7d7e0529af6e3a437edb6c6c255/tumblr_phiur//jqePq1xp0noco1_75sq.png");
// Bitmap image = //BitmapFactory.decodeStream(url.openConnection().getInputStream());
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, "VEDRISE")
.setSmallIcon(R.drawable.sunrise) // notification icon
// .setLargeIcon(image)
.setContentTitle(title) // title for notification
.setContentText(content)// message for notification
.setSound(alarmSound) // set alarm sound for notification
.setAutoCancel(true); // clear notification after click
Intent intent = new Intent(context, this.getClass());
PendingIntent pi = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(pi);
int id = (int) ((new Date().getTime() / 1000L) % Integer.MAX_VALUE);
Log.d("VedicHoroo", String.format("id: %d", id));
mNotificationManager.notify( id, mBuilder.build());


Just to give you some scope, this requirement is for local notification which will trigger by the AlarmReceiver. The receiver is triggered by Alarm without issues but the Notification does not display image which is set by setSmallIcon instead it display only the App Icon










share|improve this question






























    0















    If suppose I create Notification icons by uploading a png image using Image Asset tool from Android Studio by choosing type as notification would it generate all required icons with the dimensions as needed by notification icon spec? if Yes, then there should not be any problem displaying this icon in the notification bar, isn't it? hmm it doesn't in my case but rather it shows the default App icon no matter what. Below is my code. Any guess why its failing, perhaps this is just a cosmetic issue through.



     NotificationManager mNotificationManager =
    (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)
    NotificationChannel channel = new NotificationChannel("VEDRISE",
    "Vedic Notifications",
    NotificationManager.IMPORTANCE_DEFAULT);
    channel.setDescription("Will display daily Panchang notificatons");
    mNotificationManager.createNotificationChannel(channel);

    Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    // URL url = new //URL("https://66.media.tumblr.com/ec76b7d7e0529af6e3a437edb6c6c255/tumblr_phiur//jqePq1xp0noco1_75sq.png");
    // Bitmap image = //BitmapFactory.decodeStream(url.openConnection().getInputStream());
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, "VEDRISE")
    .setSmallIcon(R.drawable.sunrise) // notification icon
    // .setLargeIcon(image)
    .setContentTitle(title) // title for notification
    .setContentText(content)// message for notification
    .setSound(alarmSound) // set alarm sound for notification
    .setAutoCancel(true); // clear notification after click
    Intent intent = new Intent(context, this.getClass());
    PendingIntent pi = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(pi);
    int id = (int) ((new Date().getTime() / 1000L) % Integer.MAX_VALUE);
    Log.d("VedicHoroo", String.format("id: %d", id));
    mNotificationManager.notify( id, mBuilder.build());


    Just to give you some scope, this requirement is for local notification which will trigger by the AlarmReceiver. The receiver is triggered by Alarm without issues but the Notification does not display image which is set by setSmallIcon instead it display only the App Icon










    share|improve this question


























      0












      0








      0








      If suppose I create Notification icons by uploading a png image using Image Asset tool from Android Studio by choosing type as notification would it generate all required icons with the dimensions as needed by notification icon spec? if Yes, then there should not be any problem displaying this icon in the notification bar, isn't it? hmm it doesn't in my case but rather it shows the default App icon no matter what. Below is my code. Any guess why its failing, perhaps this is just a cosmetic issue through.



       NotificationManager mNotificationManager =
      (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
      if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)
      NotificationChannel channel = new NotificationChannel("VEDRISE",
      "Vedic Notifications",
      NotificationManager.IMPORTANCE_DEFAULT);
      channel.setDescription("Will display daily Panchang notificatons");
      mNotificationManager.createNotificationChannel(channel);

      Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
      // URL url = new //URL("https://66.media.tumblr.com/ec76b7d7e0529af6e3a437edb6c6c255/tumblr_phiur//jqePq1xp0noco1_75sq.png");
      // Bitmap image = //BitmapFactory.decodeStream(url.openConnection().getInputStream());
      NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, "VEDRISE")
      .setSmallIcon(R.drawable.sunrise) // notification icon
      // .setLargeIcon(image)
      .setContentTitle(title) // title for notification
      .setContentText(content)// message for notification
      .setSound(alarmSound) // set alarm sound for notification
      .setAutoCancel(true); // clear notification after click
      Intent intent = new Intent(context, this.getClass());
      PendingIntent pi = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
      mBuilder.setContentIntent(pi);
      int id = (int) ((new Date().getTime() / 1000L) % Integer.MAX_VALUE);
      Log.d("VedicHoroo", String.format("id: %d", id));
      mNotificationManager.notify( id, mBuilder.build());


      Just to give you some scope, this requirement is for local notification which will trigger by the AlarmReceiver. The receiver is triggered by Alarm without issues but the Notification does not display image which is set by setSmallIcon instead it display only the App Icon










      share|improve this question
















      If suppose I create Notification icons by uploading a png image using Image Asset tool from Android Studio by choosing type as notification would it generate all required icons with the dimensions as needed by notification icon spec? if Yes, then there should not be any problem displaying this icon in the notification bar, isn't it? hmm it doesn't in my case but rather it shows the default App icon no matter what. Below is my code. Any guess why its failing, perhaps this is just a cosmetic issue through.



       NotificationManager mNotificationManager =
      (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
      if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)
      NotificationChannel channel = new NotificationChannel("VEDRISE",
      "Vedic Notifications",
      NotificationManager.IMPORTANCE_DEFAULT);
      channel.setDescription("Will display daily Panchang notificatons");
      mNotificationManager.createNotificationChannel(channel);

      Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
      // URL url = new //URL("https://66.media.tumblr.com/ec76b7d7e0529af6e3a437edb6c6c255/tumblr_phiur//jqePq1xp0noco1_75sq.png");
      // Bitmap image = //BitmapFactory.decodeStream(url.openConnection().getInputStream());
      NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, "VEDRISE")
      .setSmallIcon(R.drawable.sunrise) // notification icon
      // .setLargeIcon(image)
      .setContentTitle(title) // title for notification
      .setContentText(content)// message for notification
      .setSound(alarmSound) // set alarm sound for notification
      .setAutoCancel(true); // clear notification after click
      Intent intent = new Intent(context, this.getClass());
      PendingIntent pi = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
      mBuilder.setContentIntent(pi);
      int id = (int) ((new Date().getTime() / 1000L) % Integer.MAX_VALUE);
      Log.d("VedicHoroo", String.format("id: %d", id));
      mNotificationManager.notify( id, mBuilder.build());


      Just to give you some scope, this requirement is for local notification which will trigger by the AlarmReceiver. The receiver is triggered by Alarm without issues but the Notification does not display image which is set by setSmallIcon instead it display only the App Icon







      android notifications notificationmanager






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 16 '18 at 10:10







      Naga

















      asked Nov 15 '18 at 16:11









      NagaNaga

      95411224




      95411224






















          1 Answer
          1






          active

          oldest

          votes


















          1














           Notification notification = new Notification.Builder(this)
          .setContentTitle(title)
          .setContentText(text)
          .setSmallIcon(R.drawable.ic_notification)
          .setContentIntent(pIntent)
          .setDefaults(Notification.DEFAULT_SOUND|Notification.DEFAULT_LIGHTS|Notification.DEFAULT_VIBRATE)
          .setAutoCancel(true)
          .build();


          Even if ic_notification is transparant and white. It must be also defined in the Manifest meta data, like so:



           <meta-data android:name="com.google.firebase.messaging.default_notification_icon"

          android:resource="@drawable/ic_notification" />


          add this line in the manifest.xml file in application block






          share|improve this answer























          • this did not work for me, the manifest setting you suggest looks like for firebase notifications, but I am not using push notification, its a local notification the daily alarm should trigger

            – Naga
            Nov 16 '18 at 10:07











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323546%2fnotification-image-never-displays-in-android%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














           Notification notification = new Notification.Builder(this)
          .setContentTitle(title)
          .setContentText(text)
          .setSmallIcon(R.drawable.ic_notification)
          .setContentIntent(pIntent)
          .setDefaults(Notification.DEFAULT_SOUND|Notification.DEFAULT_LIGHTS|Notification.DEFAULT_VIBRATE)
          .setAutoCancel(true)
          .build();


          Even if ic_notification is transparant and white. It must be also defined in the Manifest meta data, like so:



           <meta-data android:name="com.google.firebase.messaging.default_notification_icon"

          android:resource="@drawable/ic_notification" />


          add this line in the manifest.xml file in application block






          share|improve this answer























          • this did not work for me, the manifest setting you suggest looks like for firebase notifications, but I am not using push notification, its a local notification the daily alarm should trigger

            – Naga
            Nov 16 '18 at 10:07















          1














           Notification notification = new Notification.Builder(this)
          .setContentTitle(title)
          .setContentText(text)
          .setSmallIcon(R.drawable.ic_notification)
          .setContentIntent(pIntent)
          .setDefaults(Notification.DEFAULT_SOUND|Notification.DEFAULT_LIGHTS|Notification.DEFAULT_VIBRATE)
          .setAutoCancel(true)
          .build();


          Even if ic_notification is transparant and white. It must be also defined in the Manifest meta data, like so:



           <meta-data android:name="com.google.firebase.messaging.default_notification_icon"

          android:resource="@drawable/ic_notification" />


          add this line in the manifest.xml file in application block






          share|improve this answer























          • this did not work for me, the manifest setting you suggest looks like for firebase notifications, but I am not using push notification, its a local notification the daily alarm should trigger

            – Naga
            Nov 16 '18 at 10:07













          1












          1








          1







           Notification notification = new Notification.Builder(this)
          .setContentTitle(title)
          .setContentText(text)
          .setSmallIcon(R.drawable.ic_notification)
          .setContentIntent(pIntent)
          .setDefaults(Notification.DEFAULT_SOUND|Notification.DEFAULT_LIGHTS|Notification.DEFAULT_VIBRATE)
          .setAutoCancel(true)
          .build();


          Even if ic_notification is transparant and white. It must be also defined in the Manifest meta data, like so:



           <meta-data android:name="com.google.firebase.messaging.default_notification_icon"

          android:resource="@drawable/ic_notification" />


          add this line in the manifest.xml file in application block






          share|improve this answer













           Notification notification = new Notification.Builder(this)
          .setContentTitle(title)
          .setContentText(text)
          .setSmallIcon(R.drawable.ic_notification)
          .setContentIntent(pIntent)
          .setDefaults(Notification.DEFAULT_SOUND|Notification.DEFAULT_LIGHTS|Notification.DEFAULT_VIBRATE)
          .setAutoCancel(true)
          .build();


          Even if ic_notification is transparant and white. It must be also defined in the Manifest meta data, like so:



           <meta-data android:name="com.google.firebase.messaging.default_notification_icon"

          android:resource="@drawable/ic_notification" />


          add this line in the manifest.xml file in application block







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 15 '18 at 17:26









          suresh madaparthisuresh madaparthi

          251110




          251110












          • this did not work for me, the manifest setting you suggest looks like for firebase notifications, but I am not using push notification, its a local notification the daily alarm should trigger

            – Naga
            Nov 16 '18 at 10:07

















          • this did not work for me, the manifest setting you suggest looks like for firebase notifications, but I am not using push notification, its a local notification the daily alarm should trigger

            – Naga
            Nov 16 '18 at 10:07
















          this did not work for me, the manifest setting you suggest looks like for firebase notifications, but I am not using push notification, its a local notification the daily alarm should trigger

          – Naga
          Nov 16 '18 at 10:07





          this did not work for me, the manifest setting you suggest looks like for firebase notifications, but I am not using push notification, its a local notification the daily alarm should trigger

          – Naga
          Nov 16 '18 at 10:07



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323546%2fnotification-image-never-displays-in-android%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Use pre created SQLite database for Android project in kotlin

          Darth Vader #20

          Ondo