Home / Videos / BroadcastReceiver Tutorial Teil 2 – DYNAMISCHE EMPFÄNGER – Android Studio Tutorial

BroadcastReceiver Tutorial Teil 2 – DYNAMISCHE EMPFÄNGER – Android Studio Tutorial



In Teil 2 des BroadcastReceiver-Tutorials erfahren Sie, wie Sie einen BroadcastReceiver dynamisch registrieren. Anstatt den Empfänger in die Manifest-Datei aufzunehmen, registrieren wir ihn im Lebenszyklus unserer Anwendung. Auf diese Weise lebt der BroadcastReceiver so lange wie der Kontext, in dem wir ihn registrieren. Dies könnte der Anwendungskontext selbst sein, der unseren BroadcastReceiver so lange am Laufen hält, wie unsere App läuft, aber beispielsweise auch den Aktivitätskontext oder nur so lange Unsere App steht im Vordergrund.
Dazu müssen wir die registerReceiver-Methode in einer der Lifecycle-Callback-Methoden (onCreate, onStart, onResume) aufrufen und die Registrierung von Receiver in ihrem entsprechenden Gegenstück (onDestroy, onStop, onPause) aufheben.
Wenn wir unseren BroadcastReceiver registrieren, müssen wir auch einen IntentFilter übergeben, der die Aktion angibt, auf die wir hören.
Innerhalb der onReceive-Methode des BroadcastReceiver können wir auch Daten erhalten, die zusätzlich über die Broadcast-Absicht gesendet werden.

Sehen Sie sich die gesamte Wiedergabeliste an:

Beispielcode:

____________________
Abonniere den Kanal:

⏯ Weitere Tutorials ansehen:

⭐ Werden Sie Channel-Mitglied für exklusive Tutorials und andere Vorteile:

㊙ Hilf beim Übersetzen der Videos:

💚 Unterstützen Sie den Inhalt:
 

💬 Am Discord-Chat teilnehmen:

🎧 Hörbücher und Podcasts für Programmierer:
 

👶 So fangen Sie mit der Android-Entwicklung an:
 

📣 Folgen Sie Coding in Flow in den sozialen Medien:

Facebook:

Instagram:

Twitter:

Blog:
  .

About AndroidWeltEditor

Check Also

Android 10: Die Zukunft?

Bei Pocketnow Daily wechselt Google von Gebäck zu einer Umbenennung von Android in Android 10. …

25 comments

  1. what happens if your broadcast receiver was initiated at OnCreate rather than OnStart?

  2. You.. Sir.. are a great teacher indeed. Simplicity is very hard to achieve but you have attained that while explaining.. Thanks a lot..

  3. Where can I find the onCreate method of the application class? As said @4:10. Wouldn't that just be the MainActicity?

  4. Zero dislikes describes the quality of the video!!xD

  5. Sir I have a screen recording app. I want to start, pause and stop recording from notification action buttons. Which broadcast reciever would be the best for me ? Thank you in advance..

  6. is it possible to make the broadcast run altough the app is not running ??? Thanks

  7. Thank you!!
    But how to check connectivity changing when the application is killed (cleaned from recent apps)

  8. ConnectivityManager.CONNECTIVITY_ACTION is depracated. Is it a simple fix to get it working?

  9. Best Tutorials on YouTube I think, congrats. But I have one question: How can I REPLACE the TOAST with a SNACKBAR in the Receiver?? Can you send us/me a Solution for this?? In the Receiver is no VIEW, how can we do it work??

  10. How to listen to the action boot completed here ?
    Through add action method ?
    Should i add 1 more intent filter for that ?

  11. Sorry, I didn't understand if this dynamic receiver is still an implicit receiver. I need two examples of implicit broadcast receivers for my homework, and if in part one you showed us a static implicit broadcast receiver, here in part two we have a dynamic receiver, but I cannot understand if it is also implicit or not.( i thought no, because you said that in order to have an implicit broadcast receiver, we should write in the manifest file, and here we don't. yet only in the tutorial part 4 you said we were going to see explicit broadcast receivers).
    So my main simple question is:
    DO WE USE AN IMPLICIT BROADCAST RECEIVER IN HERE?
    Could you please clear this for me? Thank you so much!

  12. Thank you!! It was very helpful.👌👌👍

  13. Thanks! u great . I think if you go through little bit slow in speak that will be more interesting for our sub-continent . Whatever thanks a lot

  14. thanks, I like the tutorial. Do you have any tutorial on java web development with spring boot I want to learn it but I haven't found good tutorials

  15. gr8!! Can u pls make a tutorial on setting ringtones? like changing alarm/call/notifications tunes on button click?

  16. Sir can you provide a tutorial for realtime chat app using Firestore DB and Java?

  17. Sorry I was ill a little bit so i couldn't watch video and do programming, but now i am alright and ready to try new things.

  18. Amazing as usual my friend

Leave a Reply

Your email address will not be published. Required fields are marked *