The IP dialer uses a system-provided broadcast event when it listens for outgoing calls. There are times when we need to set up broadcast events to meet certain needs.
Ok, the whole thing today. Define the broadcast event, we use a state monitoring module to send alarm information to a 3G module to achieve this idea.
Define a 3g module to receive a specific broadcast:
<textview android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android: Layout_centerhorizontal= "true" android:layout_centervertical= "true" android:text= "I am a 3g module ~ ~ ~"/>
Then set its own definition broadcast event:
<receiver android:name= ". Mybro "> <intent-filter> <action android:name=" Com.heng.lh "/> </intent-filter> </receiver>
the com.heng.lh Here is our custom broadcast event, which is used to receive signals from specific channels.
then let's "spin the silk" for a moment. Suppose you have a broadcast of your own definition that sends a hint to the user.
public void OnReceive (context context, Intent Intent) {toast.maketext (context, "detects a broadcast event", 1). Show ();
The module receiving the broadcast is ready. Then we have to set the module to send the broadcast, the main interface needs a button to send the alarm message to the 3G module:
<button android:onclick= "click" android:layout_width= "wrap_content" android:layout_height= "wrap _content " android:layout_centerhorizontal=" true " android:layout_centervertical=" true " Android:text = "Send Message to 3G module"/>
Let's write this click event, New out an intention, and then set its action, which is what we define in front of " COM.HENG.LH "and finally with Sendbroadcast send out the information.
public void Click (View view) {Intent intent=new Intent (); Intent.setaction ("COM.HENG.LH");//Send alarm message to 3G module Sendbroadcast (intent);}
The 3G module receives a broadcast message, and a simple self-defined broadcast event is created.
Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.
Android from ignorance to knowing--no.7