The previous IP dialer uses the system-provided broadcast events when listening for outgoing calls, and sometimes we need to set up broadcast events to meet specific needs. Ok, the whole day. Custom broadcast events, we use a condition 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 custom broadcast event:
<receiver android:name= ". Mybro "> <intent-filter> <action android:name=" Com.heng.lh "/> </intent-filter> </receiver>
the com.heng.lh here is our own defined broadcast event, which is used to receive signals from a particular channel.
then let us "spin" a bit, if there is a custom broadcast sent to the user a hint.
public void OnReceive (context context, Intent Intent) {toast.maketext (context, "detected a broadcast event", 1). Show ();
The module that receives the broadcast is ready, then it is necessary to set the module to send the broadcast, the main interface needs a button to 3G module sends alarm information:
<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 intent, and then set its action, which is the custom " 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);}
This way the 3G module receives a broadcast message, and a simple custom broadcast event is created.