In part 2 of the notification tutorial, we will add a tap action to our notification that will open an activity, and we will add an action button that will trigger a BroadcastReceiver to execute some code in it’s onReceive method.
In both cases we have to create an Intent and wrap it into a PendingIntent, which we pass to our NotificationCompat.Builder. We define the tap action with setContentIntent and add our action buttons with addAction.
Also we will change the color of our notification content with setColor and specify it’s behavior with setAutoCancel and setOnlyAlertOnce.

Documentation about back stack & navigation:

Watch the whole playlist:

Example code:

____________________
❗ Subscribe to the channel:

⏯ Watch more tutorials:

⭐ Become a channel member for exclusive tutorials and other perks:

㊙ 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. is there any way to edit a notification without sending it again?

  2. Hi, any luck if you have or know a tut that discuss FCM that allows user to send notification to other user?

  3. vishal mishra Reply

    9:23 here onwards can u explain the what is happening i m not understanding

  4. Ashfan Saja Reply

    How can I send notifications on the background. When there is some change. Like a value from an api. How to detact the change in the api background, trigger a notification for that.. Thank you

  5. edi sakhnovich Reply

    How can I change play button to pause button,when I click on it?

  6. Dear sir , please make a video on this library . How can i send Notification App to App like chatting App.
    library link :https://github.com/alsheikhaminulislam/Firebase-send-notification-from-android

  7. Hi Sir, I am a newbie and have couple question:
    1) For a messaging app where I want to tell the current user that another user2 sent him a message. Suppose the user is not currently using the application on his device (all activity are closed). Does this code needs to be in a background service in order to listen to a "new message flag" (for example) in the background? Then if the new message flag is true, pass the needed message, for example, " user1 sent you a message" to your "send to channel 1" method and call it?

    2)so what would be the steps needed (High-level so we can see the general approach only) to be taken to prevent the app from opening twice after a user clicks on it just like in your video?

    3) What are the pros and cons of using this verus Firebase ( Again i'm very new and when looking up notifications on youtube, one or 2 firebase tutorial approach)

    Thank you very much for your time and anybody who provides some feedback.

  8. Dhanushka Fernando Reply

    woow ths is awesome.you are describing all the concepts very simple way.Thank you

  9. Ghulam Mustafa Reply

    when i click on notification it will open an app main screen but i want to open a particular screen as per notification please help.

  10. Talib Daryabi Reply

    I promised my self to watch all your videos, great job. thank you.

  11. Deepak shah Reply

    Explanation was good. But you should have opened emulator two times. Because you shown 2 thing.
    1. Uses of pending intent to start activity.
    2. Broadcast reciver with pending intent.
    Please don't do this in your future videos.

  12. Vidhu Tiwari Reply

    I want to send notification to my app users. Can that be done with this notification series you have uploaded.I tried firebase for notification but it seems there is a limit to number of notifications that can be sent.

  13. Kamatala Sainadh Reply

    From 1 week I working on push Notification.u solved my proble.Big Thanks .U r awesome

  14. Hey great tutorials, I have a doubt my app create multiple notifications on the same channel by passing unique ids to NotificationManagerCompat.notify() . The problem is that only the action button of the newest notification works BroadcastReceiver is not getting called when action button of old notifications are clicked.

  15. Shawn Nichol Reply

    Any suggestion on how to turn off notification from the preference menu inside the app?

  16. Is there any way I can LIKE all the videos in this playlist at once? I love your tutorial. Thanks.

  17. Is it possible to work this in fragment class instead of activity?

  18. Ankit Kumar Reply

    I have a doubt and that is…how the broadcast receiver called without any action sended by you or system…..plz clear my dobt…

Write A Comment