Android push disappears after a few seconds












0















My test phone is a Samsung Galaxy S6 using Android 7.0 Nougat.



In other apps, Android push notifications stay in the status bar, but in my app the push notification disappears after the notification is received.



Problem is DISAPPEAR NOTIFICATION FROM STATUS BAR.
Not about NOTIFICATION ALARM.
Push notification is well done working.
After ringing, there is no push in status bar.



Does anyone know about this situation?



Here is the code:



NotificationCompat.Builder builder = new 
NotificationCompat.Builder(MainActivity.this)
.setSmallIcon(R.drawable.icon_noti)
.setContentTitle('My App')
.setContentText('test')
.setDefaults(Notification.DEFAULT_SOUND)
.setPriority(Notification.PRIORITY_HIGH)
.setAutoCancel(true);

PendingIntent contentIntent = PendingIntent.getActivity(MainActivity.this,
0, new Intent(getApplicationContext(), MainActivity.class),
PendingIntent.FLAG_UPDATE_CURRENT);

builder.setContentIntent(contentIntent);

NotificationManager mNotificationManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);

mNotificationManager.notify(0, builder.build());


If someone knows about this issue, please answer.



Thanks for reading.










share|improve this question





























    0















    My test phone is a Samsung Galaxy S6 using Android 7.0 Nougat.



    In other apps, Android push notifications stay in the status bar, but in my app the push notification disappears after the notification is received.



    Problem is DISAPPEAR NOTIFICATION FROM STATUS BAR.
    Not about NOTIFICATION ALARM.
    Push notification is well done working.
    After ringing, there is no push in status bar.



    Does anyone know about this situation?



    Here is the code:



    NotificationCompat.Builder builder = new 
    NotificationCompat.Builder(MainActivity.this)
    .setSmallIcon(R.drawable.icon_noti)
    .setContentTitle('My App')
    .setContentText('test')
    .setDefaults(Notification.DEFAULT_SOUND)
    .setPriority(Notification.PRIORITY_HIGH)
    .setAutoCancel(true);

    PendingIntent contentIntent = PendingIntent.getActivity(MainActivity.this,
    0, new Intent(getApplicationContext(), MainActivity.class),
    PendingIntent.FLAG_UPDATE_CURRENT);

    builder.setContentIntent(contentIntent);

    NotificationManager mNotificationManager = (NotificationManager)
    getSystemService(Context.NOTIFICATION_SERVICE);

    mNotificationManager.notify(0, builder.build());


    If someone knows about this issue, please answer.



    Thanks for reading.










    share|improve this question



























      0












      0








      0








      My test phone is a Samsung Galaxy S6 using Android 7.0 Nougat.



      In other apps, Android push notifications stay in the status bar, but in my app the push notification disappears after the notification is received.



      Problem is DISAPPEAR NOTIFICATION FROM STATUS BAR.
      Not about NOTIFICATION ALARM.
      Push notification is well done working.
      After ringing, there is no push in status bar.



      Does anyone know about this situation?



      Here is the code:



      NotificationCompat.Builder builder = new 
      NotificationCompat.Builder(MainActivity.this)
      .setSmallIcon(R.drawable.icon_noti)
      .setContentTitle('My App')
      .setContentText('test')
      .setDefaults(Notification.DEFAULT_SOUND)
      .setPriority(Notification.PRIORITY_HIGH)
      .setAutoCancel(true);

      PendingIntent contentIntent = PendingIntent.getActivity(MainActivity.this,
      0, new Intent(getApplicationContext(), MainActivity.class),
      PendingIntent.FLAG_UPDATE_CURRENT);

      builder.setContentIntent(contentIntent);

      NotificationManager mNotificationManager = (NotificationManager)
      getSystemService(Context.NOTIFICATION_SERVICE);

      mNotificationManager.notify(0, builder.build());


      If someone knows about this issue, please answer.



      Thanks for reading.










      share|improve this question
















      My test phone is a Samsung Galaxy S6 using Android 7.0 Nougat.



      In other apps, Android push notifications stay in the status bar, but in my app the push notification disappears after the notification is received.



      Problem is DISAPPEAR NOTIFICATION FROM STATUS BAR.
      Not about NOTIFICATION ALARM.
      Push notification is well done working.
      After ringing, there is no push in status bar.



      Does anyone know about this situation?



      Here is the code:



      NotificationCompat.Builder builder = new 
      NotificationCompat.Builder(MainActivity.this)
      .setSmallIcon(R.drawable.icon_noti)
      .setContentTitle('My App')
      .setContentText('test')
      .setDefaults(Notification.DEFAULT_SOUND)
      .setPriority(Notification.PRIORITY_HIGH)
      .setAutoCancel(true);

      PendingIntent contentIntent = PendingIntent.getActivity(MainActivity.this,
      0, new Intent(getApplicationContext(), MainActivity.class),
      PendingIntent.FLAG_UPDATE_CURRENT);

      builder.setContentIntent(contentIntent);

      NotificationManager mNotificationManager = (NotificationManager)
      getSystemService(Context.NOTIFICATION_SERVICE);

      mNotificationManager.notify(0, builder.build());


      If someone knows about this issue, please answer.



      Thanks for reading.







      android push-notification






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 3:38







      JKLee

















      asked Nov 14 '18 at 1:01









      JKLeeJKLee

      357




      357
























          1 Answer
          1






          active

          oldest

          votes


















          0














          For me it works perfectly (except for the single quotes here .setContentTitle('My App') and here .setContentText('test'))!



          Maybe there are some system issues - or maybe this behavior is caused by some other part of your app.



          By the way, note that NotificationCompat.Builder is deprecated; now it requires an additional String channelId.






          share|improve this answer
























          • It work perfectly means, nougat s6 Status bar have still push text? or just alarm? push noti is well done for me too, but problem is after alarm status bar have still app push but there is no push in status bar. And we have to fix the targetSDKversion, so maybe more days or weeks ago we'll change notificationCompat. Thanks for that.

            – JKLee
            Nov 14 '18 at 4:26













          • I can't understand your problem completely - for me it works as expected. Notification is shown for a few seconds on the screen, than it appears in the status bar and remains there until clicked or dismissed. For different behavior maybe you should alter Notification.PRIORITY. Or maybe you share some screenshots?

            – MilTy
            Nov 14 '18 at 11:00













          • Basically, After notification, in status bar have Push contents(app icon, app name, push message). right? But my app push contents is disappear after notification. For a moment before notification, In status bar have push contents but after notification that is gone..

            – JKLee
            Nov 15 '18 at 0:15











          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%2f53291702%2fandroid-push-disappears-after-a-few-seconds%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









          0














          For me it works perfectly (except for the single quotes here .setContentTitle('My App') and here .setContentText('test'))!



          Maybe there are some system issues - or maybe this behavior is caused by some other part of your app.



          By the way, note that NotificationCompat.Builder is deprecated; now it requires an additional String channelId.






          share|improve this answer
























          • It work perfectly means, nougat s6 Status bar have still push text? or just alarm? push noti is well done for me too, but problem is after alarm status bar have still app push but there is no push in status bar. And we have to fix the targetSDKversion, so maybe more days or weeks ago we'll change notificationCompat. Thanks for that.

            – JKLee
            Nov 14 '18 at 4:26













          • I can't understand your problem completely - for me it works as expected. Notification is shown for a few seconds on the screen, than it appears in the status bar and remains there until clicked or dismissed. For different behavior maybe you should alter Notification.PRIORITY. Or maybe you share some screenshots?

            – MilTy
            Nov 14 '18 at 11:00













          • Basically, After notification, in status bar have Push contents(app icon, app name, push message). right? But my app push contents is disappear after notification. For a moment before notification, In status bar have push contents but after notification that is gone..

            – JKLee
            Nov 15 '18 at 0:15
















          0














          For me it works perfectly (except for the single quotes here .setContentTitle('My App') and here .setContentText('test'))!



          Maybe there are some system issues - or maybe this behavior is caused by some other part of your app.



          By the way, note that NotificationCompat.Builder is deprecated; now it requires an additional String channelId.






          share|improve this answer
























          • It work perfectly means, nougat s6 Status bar have still push text? or just alarm? push noti is well done for me too, but problem is after alarm status bar have still app push but there is no push in status bar. And we have to fix the targetSDKversion, so maybe more days or weeks ago we'll change notificationCompat. Thanks for that.

            – JKLee
            Nov 14 '18 at 4:26













          • I can't understand your problem completely - for me it works as expected. Notification is shown for a few seconds on the screen, than it appears in the status bar and remains there until clicked or dismissed. For different behavior maybe you should alter Notification.PRIORITY. Or maybe you share some screenshots?

            – MilTy
            Nov 14 '18 at 11:00













          • Basically, After notification, in status bar have Push contents(app icon, app name, push message). right? But my app push contents is disappear after notification. For a moment before notification, In status bar have push contents but after notification that is gone..

            – JKLee
            Nov 15 '18 at 0:15














          0












          0








          0







          For me it works perfectly (except for the single quotes here .setContentTitle('My App') and here .setContentText('test'))!



          Maybe there are some system issues - or maybe this behavior is caused by some other part of your app.



          By the way, note that NotificationCompat.Builder is deprecated; now it requires an additional String channelId.






          share|improve this answer













          For me it works perfectly (except for the single quotes here .setContentTitle('My App') and here .setContentText('test'))!



          Maybe there are some system issues - or maybe this behavior is caused by some other part of your app.



          By the way, note that NotificationCompat.Builder is deprecated; now it requires an additional String channelId.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 2:13









          MilTyMilTy

          86




          86













          • It work perfectly means, nougat s6 Status bar have still push text? or just alarm? push noti is well done for me too, but problem is after alarm status bar have still app push but there is no push in status bar. And we have to fix the targetSDKversion, so maybe more days or weeks ago we'll change notificationCompat. Thanks for that.

            – JKLee
            Nov 14 '18 at 4:26













          • I can't understand your problem completely - for me it works as expected. Notification is shown for a few seconds on the screen, than it appears in the status bar and remains there until clicked or dismissed. For different behavior maybe you should alter Notification.PRIORITY. Or maybe you share some screenshots?

            – MilTy
            Nov 14 '18 at 11:00













          • Basically, After notification, in status bar have Push contents(app icon, app name, push message). right? But my app push contents is disappear after notification. For a moment before notification, In status bar have push contents but after notification that is gone..

            – JKLee
            Nov 15 '18 at 0:15



















          • It work perfectly means, nougat s6 Status bar have still push text? or just alarm? push noti is well done for me too, but problem is after alarm status bar have still app push but there is no push in status bar. And we have to fix the targetSDKversion, so maybe more days or weeks ago we'll change notificationCompat. Thanks for that.

            – JKLee
            Nov 14 '18 at 4:26













          • I can't understand your problem completely - for me it works as expected. Notification is shown for a few seconds on the screen, than it appears in the status bar and remains there until clicked or dismissed. For different behavior maybe you should alter Notification.PRIORITY. Or maybe you share some screenshots?

            – MilTy
            Nov 14 '18 at 11:00













          • Basically, After notification, in status bar have Push contents(app icon, app name, push message). right? But my app push contents is disappear after notification. For a moment before notification, In status bar have push contents but after notification that is gone..

            – JKLee
            Nov 15 '18 at 0:15

















          It work perfectly means, nougat s6 Status bar have still push text? or just alarm? push noti is well done for me too, but problem is after alarm status bar have still app push but there is no push in status bar. And we have to fix the targetSDKversion, so maybe more days or weeks ago we'll change notificationCompat. Thanks for that.

          – JKLee
          Nov 14 '18 at 4:26







          It work perfectly means, nougat s6 Status bar have still push text? or just alarm? push noti is well done for me too, but problem is after alarm status bar have still app push but there is no push in status bar. And we have to fix the targetSDKversion, so maybe more days or weeks ago we'll change notificationCompat. Thanks for that.

          – JKLee
          Nov 14 '18 at 4:26















          I can't understand your problem completely - for me it works as expected. Notification is shown for a few seconds on the screen, than it appears in the status bar and remains there until clicked or dismissed. For different behavior maybe you should alter Notification.PRIORITY. Or maybe you share some screenshots?

          – MilTy
          Nov 14 '18 at 11:00







          I can't understand your problem completely - for me it works as expected. Notification is shown for a few seconds on the screen, than it appears in the status bar and remains there until clicked or dismissed. For different behavior maybe you should alter Notification.PRIORITY. Or maybe you share some screenshots?

          – MilTy
          Nov 14 '18 at 11:00















          Basically, After notification, in status bar have Push contents(app icon, app name, push message). right? But my app push contents is disappear after notification. For a moment before notification, In status bar have push contents but after notification that is gone..

          – JKLee
          Nov 15 '18 at 0:15





          Basically, After notification, in status bar have Push contents(app icon, app name, push message). right? But my app push contents is disappear after notification. For a moment before notification, In status bar have push contents but after notification that is gone..

          – JKLee
          Nov 15 '18 at 0:15


















          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%2f53291702%2fandroid-push-disappears-after-a-few-seconds%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

          Florida Star v. B. J. F.

          Danny Elfman

          Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues