‫Starting by intent filter.
‫And inside this intent filter.
‫I need to start with the action Android name and here I need to specify android dot intent dot action
‫dot airplane mode.
‫The intent filter element is an XML configuration element used in the androidmanifest.xml file to specify
‫the types of intents broadcasts, activities, services and etcetera that a component, for example,
‫an activity service or a broadcast receiver is willing to respond to.
‫It helps define the conditions under which a component can be invoked or matched.
‫And this is the root element, intent filter.
‫And here the Action action specifies the action or event that the component can respond to.
‫For example, Android dot intent action dot airplane mode.
‫I am listening.
‫I am responding to the airplane mode configuration.
‫If you hover here you can see this error.
‫I need to set the exported to true.
‫This is a very important tag or attribute.
‫Set it to true.
‫If you want other applications to send broadcasts to this receiver, run the application, go to airplane
‫mode and you can see nothing happens.
‫This is due to the latest versions of Android.
‫So as a part of Android API level 33 apps that target the API level 26 or higher can no longer register
‫broadcast receivers for implicit broadcasts in their manifest.
‫So this way is good for applications lower than API level 26.
‫You can see I am targeting API level 31.
‫This app will work for six and lower.
‫So what is the solution?
‫The solution is to go to the Android main activity register for your broadcast receivers in the activity.
‫So here I need to start by creating intent filter.
‫And we talked about intent filter and here I'm specifying Android dot intent dot action dot airplane
‫mode.
‫Then I need to start with airplane mode broadcast receiver broadcast receiver B-R equal to new airplane
‫mode receiver.
‫This is the class that we created before.
‫I need to use register receiver method to register the R, which is the broadcast receiver that we create.
‫And with the intent filter, this method is used to dynamically register a broadcast receiver in your
‫app's code.
‫I said to you that there are two ways to register a broadcast receiver, either statically in the Android
‫manifest and this is for apps that target APIs 25 and lower.
‫And this way during the runtime we need to register the broadcast.
‫This is from 26 and higher.
‫So the API level, you can see it in the Android manifest and API target here.
‫So this is the dynamic way to register a broadcast receiver and this is the static way.
‫I don't need it anymore.
‫And here we go.
‫This is our application go airplane mode and you can see this is a toast message telling us that it
‫is on go click on it again on and you can see the toast message is on.
‫So this is how to register dynamically the broadcast receiver in Android and how to create the app that
‫uses broadcast receivers.