Android Programming: The Big Nerd Ranch Guide, Third Edition
by Bill Phillips, Chris Stewart, Kristin Marsicano
For the More Curious: Detecting the Visibility of Your Fragment
When you reflect on your PhotoGallery implementation, you may notice that you used the global broadcast mechanism to broadcast the SHOW_NOTIFICATION intent.
However, you locked the receiving of that broadcast to items local to your app progress by using custom permissions.
You may find yourself asking, “Why am I using a global mechanism if I am just communicating things in my own app?
Why not a local mechanism instead?”
This is because you were specifically trying to solve the problem of knowing whether PhotoGalleryFragment was visible. The combination of ordered broadcasts, standalone receivers, and dynamically registered receivers you implemented gets the job done. There ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access