In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article "how to use broadcast to achieve static registration in Android", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this article "how to achieve static registration by broadcasting in Android".
The broadcasting mechanism in Android is more flexible, because each application can register the broadcasts it is interested in, so that the program only needs to receive the broadcast content it cares about, such as shutting down and starting WiFi.
There are two main types of broadcasts in Android:
Standard broadcast, is a completely asynchronous broadcast, after the broadcast is sent, all receivers will receive the broadcast, and almost at the same time, so there is no order before and after the broadcast, the efficiency is very high. But it also means that it can't be intercepted.
An orderly broadcast is a broadcast executed synchronously. After the broadcast is sent, only one receiver will receive the broadcast message at the same time. When all the logic of this receiver has been executed, the broadcast will continue to be transmitted to the next receiver. At this time, the receiver with high priority will receive the broadcast first and can intercept the broadcast.
So in broadcasting, the most basic thing is to register the broadcast receiver statically.
First create a new Java class, through "New/Other/Broadcast Receiver", name it MyReceiver, and add the following
Public MyReceive {public void OnReceive (Context context,Intent intent) {Toast.maetText (context, "receive a broadcast", toast.LENGTH_LONG) .show ();}}
Then add a class to MainAcitivity
Public void sendBc (View view) {sendBroadcast (new Intent (this.MyReceive.class));}
Then register with AndroidManifest.xml
Finally, create a new Button in XML and add an onclick
Android: > the above is about the content of this article on "how to use broadcast to achieve static registration in Android". I believe everyone has a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to learn more about related knowledge, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.