Android本地广播学习中一直被忽略,今天用到了,Mark一下
1、本地广播的定义和普通广播一样
例如
public class WakeTimesBroadcastReceiver extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { }}
2、本地广播的注册要用到LocalBroadcastManager
//获取本地广播
lbm= LocalBroadcastManager.getInstance(mContext);//注册广播lbm.registerReceiver(wakeTimeBroadcastReceiver,filter);
3、发送广播
Intentintent0 = new Intent();intent0.setAction("UPDATE_WAKETIMES");lbm.sendBroadcast(intent0);
4、作用
常用于在应用程序的内部实时传递信息