Playback starts YouTube’s embedded player (privacy-enhanced mode).
BroadcastReceiver Tutorial Part 8 - GOASYNC + PENDINGRESULT - Android Studio Tutorial
ChannelCoding in FlowDescription from the creator
By default, a BroadcastReceiver is only active as long as it's onReceive method runs. Once this method returns, the containing app process only becomes as important as the other components that it contains. If we don't have an activity or foreground service running, our app is considered a background process and can be killed if the system needs memory.
This becomes a problem if we start a background thread in onReceive to handle long-running operations off the UI thread, because when the process gets killed, the started thread will be terminated together with it, which can lead to unexpected behavior.
In this video, we will learn how we can use the goAsync method to tell the system that it should keep our BroadcastReceiver active for a bit longer after onReceive finished.
GoAsync returns a PendingResult which is particularly useful if we want to use our long-running receiver in combination with an ordered broadcast.
Watch the whole playlist:
youtube.com/playlist?list=PLrnPJCHvNZuBqr_0AS9B…
If you want to code along, here are the code snippets from the ordered broadcast video:
codinginflow.com/tutorials/android/broadcastrec…
Example code from this video:
gist.github.com/codinginflow/a916fcef07238dd881…
____________________
💻 Find the BEST programming tutorials on TutHub:
tuthub.io
⭐ Get my MVVM Caching Course now:
codinginflow.com/caching
❗ Subscribe to the channel:
youtube.com/c/codinginflo...
📨 Subscribe to the Coding in Flow newsletter:
codinginflow.com/newsletter
❓ Join our free developer community:
discord.gg/TSnMvmc
📣 Follow Coding in Flow on other sites:
Facebook: facebook.com/codinginflow
Instagram: instagram.com/codinginflow
TikTok: tiktok.com/@codinginflow
Twitter: twitter.com/codinginflow
Github: github.com/codinginflow
💰 Business requests, sponsoring, etc.: [email protected]
This becomes a problem if we start a background thread in onReceive to handle long-running operations off the UI thread, because when the process gets killed, the started thread will be terminated together with it, which can lead to unexpected behavior.
In this video, we will learn how we can use the goAsync method to tell the system that it should keep our BroadcastReceiver active for a bit longer after onReceive finished.
GoAsync returns a PendingResult which is particularly useful if we want to use our long-running receiver in combination with an ordered broadcast.
Watch the whole playlist:
youtube.com/playlist?list=PLrnPJCHvNZuBqr_0AS9B…
If you want to code along, here are the code snippets from the ordered broadcast video:
codinginflow.com/tutorials/android/broadcastrec…
Example code from this video:
gist.github.com/codinginflow/a916fcef07238dd881…
____________________
💻 Find the BEST programming tutorials on TutHub:
tuthub.io
⭐ Get my MVVM Caching Course now:
codinginflow.com/caching
❗ Subscribe to the channel:
youtube.com/c/codinginflo...
📨 Subscribe to the Coding in Flow newsletter:
codinginflow.com/newsletter
❓ Join our free developer community:
discord.gg/TSnMvmc
📣 Follow Coding in Flow on other sites:
Facebook: facebook.com/codinginflow
Instagram: instagram.com/codinginflow
TikTok: tiktok.com/@codinginflow
Twitter: twitter.com/codinginflow
Github: github.com/codinginflow
💰 Business requests, sponsoring, etc.: [email protected]
About this tutorial
Coding in Flow published this 7:34 video tutorial on October 25, 2019. It has been watched 13,313 times on YouTube.
- Channel
- Coding in Flow
- Category
- Science & Technology
- Duration
- 7:34
- Published
- October 25, 2019
- Views
- 13,313
- Likes
- 238
Tags
Share
Further reading
-
BroadcastReceiver Tutorial Part 8 - GOASYNC + PENDINGRESULT - Android ...
sava.video
BroadcastReceiver Tutorial Part 8 - GOASYNC + PENDINGRESULT - Android Studio Tutorial . 13 views 0 0 ...
-
Part 8 - GoAsync - Tutorials - Coding in Flow
codinginflow.com
By default, a BroadcastReceiver is only active as long as it’s onReceive method runs. Once this method returns, the containing app process only becomes as important as the other components that it contains.
-
android - How to use "goAsync" for broadcastReceiver? - Stack Overflow
stackoverflow.com
Use goAsync() if you want to handoff the processing inside of your BroadcastReceiver's onReceive() method to another thread. The onReceive() method can then be finished there. The PendingResult is passed to the new thre…
This tutorial in other languages
- FRBroadcastReceiver Tutoriel Partie 8 - GOASYNC + PENDINGRESULT - Android studio Tutorial
- ESBroadcastReceiver Tutorial Parte 8 - GOASYNC + PENDINGRESULT - Android Studio Tutorial
- PTBroadcastReceiver Tutorial Parte 8 - GOASYNC + PENDINGRESULT - Android Estúdio Tutorial
- ITBroadcastReceiver Tutorial Parte 8 - GOASYNC + PENDINGRESULT - Android Studio Tutorial
- DEBroadcastReceiver Tutorial Teil 8 - GOASYNC + PENDINGRESULT - Android Studio Tutorial
- NLBroadcastReceiver Tutorial Deel 8 - GOASYNC + PENDINGRESULT - Android Studio Tutorial
- RUBroadcastReceiver Учебник Часть 8 - GOASYNC + PENDINGRESULT - Android-студия Tutorial
- PLBroadcastReceiver Tutorial Part 8 - GOASYNC + PENDINGRESULT - Android Studio Tutorial
- JABroadcastReceiverチュートリアルパート8 - GOASYNC + PENDINGRESULT - のAndroid Studioチュートリアル
- ARBroadcastReceiver دروس الجزء 8 - GOASYNC + PENDINGRESULT - الروبوت التعليمي ستوديو
- HIBroadcastReceiver ट्यूटोरियल भाग 8 - GOASYNC + PENDINGRESULT - एंड्रॉयड स्टूडियो ट्यूटोरियल
- IDBroadcastReceiver Tutorial Part 8 - GOASYNC + PENDINGRESULT - Android Studio Tutorial