HDTutorial
EN

Playback starts YouTube’s embedded player (privacy-enhanced mode).

BroadcastReceiver Tutorial Part 8 - GOASYNC + PENDINGRESULT - Android Studio Tutorial

13,313 views October 25, 2019 7:34

Watch on YouTube
ChannelCoding in Flow

Description 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]

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.

Duration
7:34
Published
October 25, 2019
Views
13,313
Likes
238

Tags

Share

Further reading

This tutorial in other languages