In this video series we will learn everything about notifications in Android.
In part 1 we will start by creating notification channels (Categories) which are necessary since Android Oreo (API level 26) to be able to show any notifications. These channels should be created as soon as we start our app, so we will do it in the onCreate method of a class that extends Application.
When we create these channels, we have to pass an ID, a name and an importance level. Additionally we can customize the channel further, like enabling the LED, activating vibration or changing the sound, but the user has ultimate control over the channel’s behavior.
When our NotificationChannel objects are created, we pass them to the NotificationManager’s createNotificationChannel method.
When we then want to show a notification, we create it with the NotificationCompat.Builder, where we can set a title, a message, an icon, a priority level, a category and many more customization options, and then we pass this
Notification object to the NotificationManagerCompat’s notify method, where we also have to pass an ID which we can later use to update or cancel this particular notification.

Documentation:
NotificationManager:

NotificationChannel:

NotificationCompat:

NotificationCompat.Builder:

Watch the whole playlist:

Example code:

____________________
❗ Subscribe to the channel:

⏯ Watch more tutorials:

㊙ Help translating the videos:

💚 Support the content:

💬 Join the Discord chat:

🎧 Audiobooks and podcasts for programmers:

👶 How to get started with Android development:

📣 Follow Coding in Flow on social media:

Facebook:

Instagram:

Twitter:

Blog:

Nguồn:https://u-os.org/

Xem Thêm Bài Viết Khác:https://u-os.org/cong-nghe

Author

30 Comments

  1. Stanislav Omelchenko Reply

    Thank. It works. But I don't understand what is the point of sending notifications to yourself. I installed the same application on another phone and received a notification on only one. A better way to use Firebase for that. I'm right?

  2. Ryan Guitar Godfrey Reply

    I'm newer to Android and writing a social media app. I've got friend requests working but wanted to know how to send a notification upon sending a friend request. Can I customize this to do that? Thanks😎

  3. Daniel Goldbach Reply

    Kannst dus nicht auch gleich auf deutsch machen xD

  4. Federico Airola Reply

    Thanks for your helpful explanation!
    I have a little request.
    At 5:49 you show some very interesting settings to customize the way notifications arrive on the smartphone. I have to set up this strings (channel1.set…) in order to enable all possibilities and get a full alerting notification, but I don't know how to deal with arguments in the (). Can you write me above this comment a little peace of code to enable a full-alarm notification? I mean with default sound, vibration, LEDs etc…
    Thank you, unfortunately I didn't find any guidelines to write it by myself. I don't know how this strings work.

  5. Sampelmind81 Reply

    Hey, i need your advice! Lets say i released an app on the google play store and a few months later i like to provide an update to all the users, that already downloaded my app. Is it allowed to load this update directly from a server like firestore to the app? Thanks!

  6. Naman Jain Reply

    Sir , Can we build an app by which we could send notification to multiple mobile phones having that same app somewhat like app to app communication.
    Sir plz help me kinda stucked .
    If could build then share full process..

  7. Gordon Freeman Reply

    why did you call the Notification object NotificationCompat.Builder? what we need to use. NotificationCompat.Builder vs Notification.Builder .. which version is more suitable for which one. Thank you!

  8. giannis fragoulis Reply

    What if we want to switch the vibration (channel.setVibrationPattern) with our app settings?? Because it's default settings and cannot be changed..how can this be done?

  9. Louis Murphy Reply

    Thank you for the video.

    I have a question : if I run that app with the notification feature on multiple devices (5devices ). Can one end share one notification to all those devices ??

  10. Its giving error on (new NotificationCompat) plz help me

  11. Does creating these in the App class take up memory for the life of the app?

  12. the public Reply

    am trying for like a week to create a NCH to kitkat and it didn't work keep saying that its required 26API 😔

  13. How to send information like messenger

    on Android and IOS Devices will show a notification

  14. How can we send notification to the specific email address?

  15. Jason Panella Reply

    Do you have any videos/tutorials on pending notifications?

  16. Marek Štorek Reply

    Nice tutorial!
    But..
    I have little problem. After clicking one of the button the notification doesnt show, I can only see logo on the topbar, or when I scroll down.
    However it is Nice VIDEO –> Like & Subscribe given

  17. Fayssal El Ansari Reply

    hans, can you please make a geofencing tutorial?

  18. Joseph Ali Reply

    I'm creating an app which receive notifications from FCM. I'm able to get notifications while the app in foreground or in the background. I have 2 testing phones :{ Vivo : Pie 9 } and {OnePlus 1: Marshmallow }

    Vivo could't receive the notification if the app is killed. However, OnePlus could receive the notification.

  19. Timothy Maina Reply

    Thanks a lot , I understand you better than my college professor

  20. SandraNitu Reply

    thank you for the video and the source code . it works greate !

  21. Harvinder Singh Reply

    notification dot isn't visible even if it is enabled in the app settings ?

  22. Hello sir, how can I retrieve those inputted data to show in an activity instead of showing in notification? Thanks ahead.

  23. Nemanja Tomanović Reply

    This is great tutorial, this is your first tutorial that I'm watching but now I'm gonna check the rest for sure :). Keep it up bro 👍

Write A Comment