I wrote a standard code for displaying notifications in MainActivity, but it is not displayed and does not generate an error. Code in OnCreate:

Intent notificationIntent = new Intent(this, MainActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); Resources res = this.getResources(); NotificationCompat.Builder builder = new NotificationCompat.Builder(this); Notification notification = builder.setContentIntent(contentIntent) .setSmallIcon(R.drawable.walk) .setContentTitle(res.getString(R.string.route_notif_title)) .setContentText(res.getString(R.string.route_notif_text)) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .build(); NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(112, notification); 
  • What version of android? - katso
  • @katso device Android 8.1 sdk 27, minSdkVersion 23 compileSdk 26 - Dmitry Paramonov
  • You have not created a notification channel, your notification went to dev / null. developer.android.com/training/notify-user/build-notification - Yura Ivanov
  • @YuraIvanov thanks, it all worked - Dmitry Paramonov

0