做网站必须备案吗,网站建设平台怎么做,萧山人才网手机版,什么做网站做个网站一般要多少钱啊的ip拨号器在监听外拨电话时用的是系统提供的广播事件。而有些时候我们须要自己设定广播事件来满足特定的须要。Ok#xff0c;今天整一下自己定义广播事件#xff0c;我们用一个状态监測模块向一个3G模块发送报警信息来实现这一想法。 先定义一个3g模块用来接收特定的广播今天整一下自己定义广播事件我们用一个状态监測模块向一个3G模块发送报警信息来实现这一想法。 先定义一个3g模块用来接收特定的广播 TextViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_centerHorizontaltrueandroid:layout_centerVerticaltrueandroid:text俺是一个3g模块~~~~ / 然后设置它的自己定义广播事件 receiver android:name.MyBrointent-filteraction android:namecom.heng.lh//intent-filter
/receiver 这里的com.heng.lh是我们自定义的广播事件用来接收特定频道的信号。 然后让我们“吐丝”一下。假设有自己定义的广播发过来便给用户一个提示。 public void onReceive(Context context, Intent intent) {Toast.makeText(context, 检測到一个广播事件,1).show();} 接收广播的模块做好了。然后就要设定发送广播的模块了主界面须要一个button来向3G模块发送报警信息 Buttonandroid:onClickclickandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_centerHorizontaltrueandroid:layout_centerVerticaltrueandroid:text向3G模块发送信息 / 我们来写一下这个点击事件new出来一个意图然后设定它的动作也就是我们前面自己定义的“com.heng.lh”最后用sendBroadcast把信息发送出去。 public void click(View view){Intent intentnew Intent();intent.setAction(com.heng.lh);//把报警信息发送给3G模块sendBroadcast(intent);} 这样3G模块便会收到一个广播信息一个简单的自己定义广播事件也就创建好了。 版权声明本文博主原创文章博客未经同意不得转载。