Android Programming: The Big Nerd Ranch Guide, Third Edition
by Bill Phillips, Chris Stewart, Kristin Marsicano
Filtering Foreground Notifications
With that sharp corner filed down a bit, let’s turn to another imperfection in PhotoGallery. Your notifications work great, but they are sent even when the user already has the application open.
You can fix this problem with broadcast intents, too. But they will work in a completely different way.
First, you will send (and receive) your own custom broadcast intent (and ultimately will lock it down so it can be received only by components in your application). Second, you will register a receiver for your broadcast dynamically in code, rather than in the manifest. Finally, you will send an ordered broadcast to pass data along a chain of receivers, ensuring a certain receiver is run last. (You do not ...
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