In part 3 of the BroadcastReceiver tutorial, we will send and receive an implicit custom broadcast with an intent action string that we define ourselves. The same as system broadcast our custom broadcast can contain extra data, which we add by calling putExtra on the intent and passing a value together with a name. We then pass our intent to the sendBroadcast method, which will send the broadcast immediately and trigger all BroadcastReceivers that were registered dynamically with the registerReceiver method.
To access the variables in our Activity, we can add the BroadcastReceiver as an inner class and update the UI in it’s onReceive method directly.
Watch the whole playlist:
❗ 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:
Xem thêm Bài Viết:
- Chia sẻ đầy đủ về cách hướng dẫn Ghost Win Xp bằng USB cơ bản từ A tới Z
- Hướng dẫn tạo file ghost win 10 thông qua 3 bước đơn giản mà bạn không nên bỏ qua
- Mách bạn 4 bước trong cách bung file tib theo chuẩn UEFI đơn giản nhất
- Mật bí 4 kiểu hyperlink trong excel bị lỗi phổ biến mà bạn hay gặp nhất
- Khái niệm ma alt là gì và cách sử dụng bảng mã ATL như thế nào?
@5:20 it's confusing naming the function sendBroadcast cause if you wouldn't know about overloading it would seem the function is making intents and after that it calls itself to make a new intent and after that make a new intent then call itself and make a new intent etc etc. PS great videos, many thanks
I've been following your tutorials as they give clear picture of android workflow than any other online tutorials. Thank you and keep doing more. I have a doubt regarding this tutorial. As onReceive() is triggered only when is a broadcast received, we didn't send any broadcast from 1st app. I wonder how onRecieve() of 2nd app is getting triggered as it's updating UI with extra from received intent. Please help!
Hello do you know how to make a announcements using Broadcast?
As you told if we want to keep broadcast receiver active as long as app is running then register it in oncreate() of Application class then where should we unregister it?
Hey, I don't get how the method 'sendBroadcast' gets invoked and my app isn't working.
Why do we use these pairs to register & unregister: (onCreate() & onDestroy()), (onStart() & onStop()), (onPause() & onResume()) . I mean I understand foreground/background difference, but is there anything wrong with registering in onStart() and unregistering in onDestroy(), for example? Do we HAVE TO stick to those pairs for some reason?
can you upload the whole project of the source code ? put it like in zip file.
good job sir
Good job, but I have a problem. For me receiving Toast message works only on emulator but not on my phone.
Did you save the new project in the same directory as the old project ?
THANKS FOR THIS COURSE BUT I DID NOT RECEIVED TOAST MESSAGE
7:55 are you sure that when you close your app onDestroy callback method is called??
Because I think that sometimes onDestroy isn't called when you close your app.
Check this out: https://stackoverflow.com/questions/41744933/android-ondestroy-isnt-called-when-i-close-the-app-from-the-recent-apps-button
He is the god in the world of android developing learning on YouTube! ♥☺
Puedes agregar subtitulos en español?
I was on your website moment ago. I read your "biography" and I am impressed just keep going.