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
However, you locked the receiving of that broadcast to items local to your app process by using custom permissions.
You may find yourself asking, “Why am I using a global mechanism if I am just communicating with 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. ...