Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 188.8.131.52 release ready!
Owner and Founder. Opencart
Broadcast helps the Android application to send or receive a Broadcast message from the system or from another application. The system generates broadcasts when various events occur. So in this blog, we are discussing the Android local broadcast.
Android broadcast will help to send or receive any event at run time. For example, if you are developing an alarm-based application then at the time of the alarm with the broadcast event you can play the audio and perform any other action.
Broadcast are of two types:
Static broadcast receiver: These broadcast receivers are declared on the manifest file. These broadcast receivers work even if the application is closed.
Dynamic broadcast receiver: These are not declared on the manifest mostly used for the case when the application is running.
When we want to send or receive data in a different application at that time it is best to use the broadcast. But when the data for sharing is limited and is shared on the same application then it’s better to use Android local broadcast.
Android local broadcast will help to keep your data private as no other application will be able to send the broadcast to your application.
Add below dependency in your app-level build.gradle file for an older project like.
For sending the local broadcast just create the instance of the LocalBroadcastManager and call the sendBroadcast()
For sending broadcast we have created intent and passed some information on the intent.
After the Intent creation we have passed the intent inside the sendBroadcast()
It’s time to receive the local broadcast that we have created in the previous step.
Create the broadcast receiver inside your receiving activity like below:
Now register your receiver like below:
Here registerReceiver() is using the broadcast receiver and your intent action that we have created during the send broadcast.
Once you compleated the work through your broadcast we can unregister it like below:
In this blog, you have learned about the implementation of the Android local broadcast.
For more information regarding the Android broadcast follow the link.
Thanks for reading this blog. You can also check other blogs from here.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
When I think in getting solutions for my Ecommerce Platform, I think of Webkul. They have been such a blessing in our business. We have spent thousands of dollars in support and modules from them. We love their support team. They work very closely with us, and they always go the extra mile when we need help.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.