-1

i try all codes and i try official code from google But Nothing work on my Device and Emulator

i get a Many code from YouTube and Google and Many Blogs But Nothing work too

// i try that

     NotificationManager notificationManager
 = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);    
   Notification notification = new 
Notification.Builder(MainActivity.this)

       .setContentTitle("This is a Notification")
       .setContentText("Please pay Your Attention here..!")

      .setSmallIcon(R.drawable.ic_launcher_foreground)

      .setAutoCancel(true)

       .build();
      notificationManager.notify(CHANNEL_ID1,notification);
           }
                   });

// and try that

  NotificationCompat.Builder builder = 
  new NotificationCompat.Builder(this, 
  CHANNEL_ID)

    .setSmallIcon(R.drawable.notification_icon)

    .setContentTitle(textTitle)

    .setContentText(textContent)

.setPriority(NotificationCompat.PRIORITY_DEFAULT);

//Nothing work

the code should Push a Notification on android 8 and 9

and be better if get too one work from android 4.4

1 Answers1

0

In Android O it's a must to use a channel with your Notification Builder

please look at this answer https://stackoverflow.com/a/43093261/8577615

Ahmed Abdalla
  • 2,356
  • 2
  • 14
  • 27