FATAL EXCEPTION when useing setSmallIcon(Icon i) On Android 6.0.12019 Community Moderator ElectionClose/hide the Android Soft KeyboardHow do I pass data between Activities in Android application?Is there a unique Android device ID?What is the difference between gravity and layout_gravity in Android?How to get the build/version number of your Android application?Set icon for Android applicationAndroid: catching application exitProper use cases for Android UserManager.isUserAGoat()?Android Studio: Add jar as library?Fatal Exception: android.app.RemoteServiceException … Couldn't create icon: StatusBarIcon

PTIJ: Why do we make a Lulav holder?

Imaginary part of expression too difficult to calculate

Air travel with refrigerated insulin

UK Tourist Visa- Enquiry

Knife as defense against stray dogs

How to understand 「僕は誰より彼女が好きなんだ。」

What is the difference between something being completely legal and being completely decriminalized?

Why is participating in the European Parliamentary elections used as a threat?

Why I don't get the wanted width of tcbox?

What will the Frenchman say?

Do people actually use the word "kaputt" in conversation?

Error in master's thesis, I do not know what to do

Print a physical multiplication table

Recursively updating the MLE as new observations stream in

Why doesn't the fusion process of the sun speed up?

Homology of the fiber

Which partition to make active?

Exit shell with shortcut (not typing exit) that closes session properly

Isn't the word "experience" wrongly used in this context?

How to find the largest number(s) in a list of elements, possibly non-unique?

is this saw blade faulty?

Fair way to split coins

Single word to change groups

I got the following comment from a reputed math journal. What does it mean?



FATAL EXCEPTION when useing setSmallIcon(Icon i) On Android 6.0.1



2019 Community Moderator ElectionClose/hide the Android Soft KeyboardHow do I pass data between Activities in Android application?Is there a unique Android device ID?What is the difference between gravity and layout_gravity in Android?How to get the build/version number of your Android application?Set icon for Android applicationAndroid: catching application exitProper use cases for Android UserManager.isUserAGoat()?Android Studio: Add jar as library?Fatal Exception: android.app.RemoteServiceException … Couldn't create icon: StatusBarIcon










0















I am trying to make a dynamic small icon on Notification bar. And it worked well on Android 8.0.0. But there is problem on Android 6.0.1.



Here is the code:



Intent notificationIntent = new Intent(getApplicationContext(), ResumeMainActivity.class);
intent.putExtra("type", "exit");
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(),
0, notificationIntent, 0);
Bundle a = new Bundle();
a.putString("type", "exit");

Intent snoozeIntent = new Intent(getApplicationContext(), Foreground.class);
snoozeIntent.putExtra(EXTRA_NOTIFICATION_ID, 0);
snoozeIntent.setAction("Stop");
PendingIntent snoozePendingIntent =
PendingIntent.getService(getApplicationContext(), 0, snoozeIntent, 0);


Notification.Builder notification = null;
NotificationCompat.Builder notificationBelow = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
notification = new Notification.Builder(getApplicationContext())
.setContentTitle("Title")
.setContentText("Tap to open app.")
.setSmallIcon(Icon.createWithBitmap(drawText(totalDataSent, totalDataCollected)))

.setContentIntent(pendingIntent)
.setExtras(a);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
notification.setChannelId(CHANNEL_ID);

notification.addAction(new Notification.Action.Builder(Icon.createWithResource(getApplicationContext(), R.drawable.ic_launcher_foreground), "Stop", snoozePendingIntent).build());
else
notificationBelow = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID)
.setContentTitle("Title")
.setContentText("Tap to open app.")
.setSmallIcon(R.drawable.ic_launcher_background)
.setContentIntent(pendingIntent)
.setExtras(a)
.setChannelId(CHANNEL_ID)
.addAction(R.drawable.ic_launcher_foreground, "Stop", snoozePendingIntent);

NotificationManager manager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
manager.notify(1, notification.build());
else
manager.notify(1, notificationBelow.build());



And I get Couldn't update icon: StatusBarIcon(icon=Icon(typ=RESOURCE pkg=com.example.app id=0x00000000) visible user=0 )



Here is the error:



E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.app, PID: 20774
android.app.RemoteServiceException: Bad notification posted from package com.example.app: Couldn't update icon: StatusBarIcon(icon=Icon(typ=RESOURCE pkg=com.example.app id=0x00000000) visible user=0 )
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2019)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)









share|improve this question




























    0















    I am trying to make a dynamic small icon on Notification bar. And it worked well on Android 8.0.0. But there is problem on Android 6.0.1.



    Here is the code:



    Intent notificationIntent = new Intent(getApplicationContext(), ResumeMainActivity.class);
    intent.putExtra("type", "exit");
    PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(),
    0, notificationIntent, 0);
    Bundle a = new Bundle();
    a.putString("type", "exit");

    Intent snoozeIntent = new Intent(getApplicationContext(), Foreground.class);
    snoozeIntent.putExtra(EXTRA_NOTIFICATION_ID, 0);
    snoozeIntent.setAction("Stop");
    PendingIntent snoozePendingIntent =
    PendingIntent.getService(getApplicationContext(), 0, snoozeIntent, 0);


    Notification.Builder notification = null;
    NotificationCompat.Builder notificationBelow = null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
    notification = new Notification.Builder(getApplicationContext())
    .setContentTitle("Title")
    .setContentText("Tap to open app.")
    .setSmallIcon(Icon.createWithBitmap(drawText(totalDataSent, totalDataCollected)))

    .setContentIntent(pendingIntent)
    .setExtras(a);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
    notification.setChannelId(CHANNEL_ID);

    notification.addAction(new Notification.Action.Builder(Icon.createWithResource(getApplicationContext(), R.drawable.ic_launcher_foreground), "Stop", snoozePendingIntent).build());
    else
    notificationBelow = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID)
    .setContentTitle("Title")
    .setContentText("Tap to open app.")
    .setSmallIcon(R.drawable.ic_launcher_background)
    .setContentIntent(pendingIntent)
    .setExtras(a)
    .setChannelId(CHANNEL_ID)
    .addAction(R.drawable.ic_launcher_foreground, "Stop", snoozePendingIntent);

    NotificationManager manager = (NotificationManager)
    context.getSystemService(Context.NOTIFICATION_SERVICE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
    manager.notify(1, notification.build());
    else
    manager.notify(1, notificationBelow.build());



    And I get Couldn't update icon: StatusBarIcon(icon=Icon(typ=RESOURCE pkg=com.example.app id=0x00000000) visible user=0 )



    Here is the error:



    E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.app, PID: 20774
    android.app.RemoteServiceException: Bad notification posted from package com.example.app: Couldn't update icon: StatusBarIcon(icon=Icon(typ=RESOURCE pkg=com.example.app id=0x00000000) visible user=0 )
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2019)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:158)
    at android.app.ActivityThread.main(ActivityThread.java:7224)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)









    share|improve this question


























      0












      0








      0








      I am trying to make a dynamic small icon on Notification bar. And it worked well on Android 8.0.0. But there is problem on Android 6.0.1.



      Here is the code:



      Intent notificationIntent = new Intent(getApplicationContext(), ResumeMainActivity.class);
      intent.putExtra("type", "exit");
      PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(),
      0, notificationIntent, 0);
      Bundle a = new Bundle();
      a.putString("type", "exit");

      Intent snoozeIntent = new Intent(getApplicationContext(), Foreground.class);
      snoozeIntent.putExtra(EXTRA_NOTIFICATION_ID, 0);
      snoozeIntent.setAction("Stop");
      PendingIntent snoozePendingIntent =
      PendingIntent.getService(getApplicationContext(), 0, snoozeIntent, 0);


      Notification.Builder notification = null;
      NotificationCompat.Builder notificationBelow = null;
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
      notification = new Notification.Builder(getApplicationContext())
      .setContentTitle("Title")
      .setContentText("Tap to open app.")
      .setSmallIcon(Icon.createWithBitmap(drawText(totalDataSent, totalDataCollected)))

      .setContentIntent(pendingIntent)
      .setExtras(a);
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
      notification.setChannelId(CHANNEL_ID);

      notification.addAction(new Notification.Action.Builder(Icon.createWithResource(getApplicationContext(), R.drawable.ic_launcher_foreground), "Stop", snoozePendingIntent).build());
      else
      notificationBelow = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID)
      .setContentTitle("Title")
      .setContentText("Tap to open app.")
      .setSmallIcon(R.drawable.ic_launcher_background)
      .setContentIntent(pendingIntent)
      .setExtras(a)
      .setChannelId(CHANNEL_ID)
      .addAction(R.drawable.ic_launcher_foreground, "Stop", snoozePendingIntent);

      NotificationManager manager = (NotificationManager)
      context.getSystemService(Context.NOTIFICATION_SERVICE);
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
      manager.notify(1, notification.build());
      else
      manager.notify(1, notificationBelow.build());



      And I get Couldn't update icon: StatusBarIcon(icon=Icon(typ=RESOURCE pkg=com.example.app id=0x00000000) visible user=0 )



      Here is the error:



      E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.app, PID: 20774
      android.app.RemoteServiceException: Bad notification posted from package com.example.app: Couldn't update icon: StatusBarIcon(icon=Icon(typ=RESOURCE pkg=com.example.app id=0x00000000) visible user=0 )
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2019)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:158)
      at android.app.ActivityThread.main(ActivityThread.java:7224)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)









      share|improve this question
















      I am trying to make a dynamic small icon on Notification bar. And it worked well on Android 8.0.0. But there is problem on Android 6.0.1.



      Here is the code:



      Intent notificationIntent = new Intent(getApplicationContext(), ResumeMainActivity.class);
      intent.putExtra("type", "exit");
      PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(),
      0, notificationIntent, 0);
      Bundle a = new Bundle();
      a.putString("type", "exit");

      Intent snoozeIntent = new Intent(getApplicationContext(), Foreground.class);
      snoozeIntent.putExtra(EXTRA_NOTIFICATION_ID, 0);
      snoozeIntent.setAction("Stop");
      PendingIntent snoozePendingIntent =
      PendingIntent.getService(getApplicationContext(), 0, snoozeIntent, 0);


      Notification.Builder notification = null;
      NotificationCompat.Builder notificationBelow = null;
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
      notification = new Notification.Builder(getApplicationContext())
      .setContentTitle("Title")
      .setContentText("Tap to open app.")
      .setSmallIcon(Icon.createWithBitmap(drawText(totalDataSent, totalDataCollected)))

      .setContentIntent(pendingIntent)
      .setExtras(a);
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
      notification.setChannelId(CHANNEL_ID);

      notification.addAction(new Notification.Action.Builder(Icon.createWithResource(getApplicationContext(), R.drawable.ic_launcher_foreground), "Stop", snoozePendingIntent).build());
      else
      notificationBelow = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID)
      .setContentTitle("Title")
      .setContentText("Tap to open app.")
      .setSmallIcon(R.drawable.ic_launcher_background)
      .setContentIntent(pendingIntent)
      .setExtras(a)
      .setChannelId(CHANNEL_ID)
      .addAction(R.drawable.ic_launcher_foreground, "Stop", snoozePendingIntent);

      NotificationManager manager = (NotificationManager)
      context.getSystemService(Context.NOTIFICATION_SERVICE);
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
      manager.notify(1, notification.build());
      else
      manager.notify(1, notificationBelow.build());



      And I get Couldn't update icon: StatusBarIcon(icon=Icon(typ=RESOURCE pkg=com.example.app id=0x00000000) visible user=0 )



      Here is the error:



      E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.app, PID: 20774
      android.app.RemoteServiceException: Bad notification posted from package com.example.app: Couldn't update icon: StatusBarIcon(icon=Icon(typ=RESOURCE pkg=com.example.app id=0x00000000) visible user=0 )
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2019)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:158)
      at android.app.ActivityThread.main(ActivityThread.java:7224)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)






      android android-notifications android-notification-bar






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 7 at 1:53









      c-an

      547426




      547426










      asked Mar 6 at 23:38









      Erik SahakyanErik Sahakyan

      11




      11






















          0






          active

          oldest

          votes











          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%2f55033892%2ffatal-exception-when-useing-setsmalliconicon-i-on-android-6-0-1%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          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%2f55033892%2ffatal-exception-when-useing-setsmalliconicon-i-on-android-6-0-1%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

          1928 у кіно

          Захаров Федір Захарович

          Ель Греко