From the course: Android App Development: Enterprise Integration
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Listen for restriction changes: String and bool - Android Tutorial
From the course: Android App Development: Enterprise Integration
Listen for restriction changes: String and bool
- [Narrator] To listen for changes to our application restrictions, we should create a new broadcast receiver within our activity. Let's call this the restrictionsReceiver. Next, let's define a new intent filter. I'll call this the restrictionsFilter. Let's create a new intent filter for intents, with the action of action application restrictions changed. Next, we can define our broadcast receiver as a new broadcast receiver, and in our onReceive method, we can process our restrictions. Let's copy and paste what we did in our onResume method to make our lives a little bit easier. And don't forget to use a semicolon. The difference here being that now that we are not on the UI thread, we need to make sure that we post a new runnable for our image button that updates the state of the button. Then we should make sure that we register the receiver using the restrictions filter. And lastly, scroll down, ctrl + o for override, onDestroy. Should always make sure to unregister our receivers…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.