0

I have problem with notification system , why not show up with some devices like modern devices ?

Intent intent = new Intent(this, TestClass.class);
                Notification n = new Notification.Builder(this)
                        .setContentTitle(getResources().getString(R.string.app_name))
                        .setContentText(getResources().getString(R.string.notification_content_text))
                        .setSmallIcon(R.drawable.notification_small_icon)
                        .setContentIntent(PendingIntent.getActivity(this, 0, intent, 0))
                        .setAutoCancel(true)
                        .setOngoing(true)
                        .build();
                NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
                notificationManager.notify(0, n);

I had tried with this problem via another subjects but useless , I hope you can help me.

Taha Sami
  • 1,565
  • 1
  • 16
  • 43
  • 1
    You need to use `NotificationChannel`s, starting with Oreo. Make sure to read both of the top two answers on the linked duplicate; i.e., https://stackoverflow.com/a/43093261 and https://stackoverflow.com/a/44534559. – Mike M. Dec 18 '18 at 18:34
  • @MikeM. do you can read my subject in last line :) – Taha Sami Dec 18 '18 at 18:36
  • Yes, I did, in fact, read your whole question, twice. However, the code you've shown is not anywhere near compliant with current requirements. If you're having trouble implementing `NotificationChannel`s, then you need to show us that specific code, not something that's just guaranteed not to work. – Mike M. Dec 18 '18 at 18:38
  • @MikeM. can you show me what is NotificationChannels ? – Taha Sami Dec 18 '18 at 18:40
  • @MikeM. codes in above old or not ? – Taha Sami Dec 18 '18 at 18:41
  • I've linked you to a question here with rather explicit examples. If you'd like to read the official developer guide, that can be found here: https://developer.android.com/training/notify-user/channels. – Mike M. Dec 18 '18 at 18:42
  • 1
    @MikeM. thank you mike <3 – Taha Sami Dec 18 '18 at 18:44

0 Answers0