用于接收外部事件(注意BroadcastReceiver是用时创建用完后即摧毁的)
1,获取
a,注册 Context.registerReceiver (BroadcastReceiver receiver, IntentFilter filter)
receiver 为获取BroadcastReceiver事件的类
filter 事件过滤器为sendBroadcast中的intent
与之对应的Context.unregisterReceiver (BroadcastReceiver receiver)
或在<application>节内添加
<receiver android:name=".接收事件BoardCastReceiver类">
<intent-filter android:name="要接受的事件">
</intent-filter>
</receiver>
b,继承该类须实现 public void onReceive(Context context, Intent intent)方法
2,产生
Context.sendBroadcast
如果传入的参数是Intent(name)那么name应该等于<intent-filter android:name="要接受的事件">