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
Xem thêm Bài Viết:
- Hướng dẫn cách lắp anten ngoài trời đúng kỹ thuật, thu sóng khỏe nhất
- Giải đáp bí ẩn Xamarin là gì? Ưu và nhược điểm khi sử dụng Xamarin
- Tuyệt chiêu sửa lỗi window photo viewer can’t open this picture because
- Bộ nhớ đệm là gì? Có nên xóa bộ nhớ đệm trên thiết bị không?
- Bật mí 3 cách chụp ảnh bằng máy tính win 7 dễ như ăn kẹo
30 Comments
Thnk u so mch… This method workd 4 me…
Hey why are you using broadcast receiver for action button?
is there any way to edit a notification without sending it again?
Hi, any luck if you have or know a tut that discuss FCM that allows user to send notification to other user?
9:23 here onwards can u explain the what is happening i m not understanding
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
How can I change play button to pause button,when I click on it?
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
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.
woow ths is awesome.you are describing all the concepts very simple way.Thank you
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.
I promised my self to watch all your videos, great job. thank you.
Can i make a notification from setonclicklistiner ?
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.
superb tutorials sir
hi bro r u there i need a little bit help from u
Thanks..It really helped me.
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.
From 1 week I working on push Notification.u solved my proble.Big Thanks .U r awesome
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.
ভালো
I searched hours for a good tutorial. Thanks man! Big love!
Any suggestion on how to turn off notification from the preference menu inside the app?
Thank you from Brazil!
not working
I want to make that notification default how to do that
Is there any way I can LIKE all the videos in this playlist at once? I love your tutorial. Thanks.
Is it possible to work this in fragment class instead of activity?
Great tut as always!
I have a doubt and that is…how the broadcast receiver called without any action sended by you or system…..plz clear my dobt…