activity中使用BroadcserReceiver
只要在onCreate()中注册
// 注册广播
receiver = new ShopDetailBroadcserReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("com.szx.YYY");
this.registerReceiver(receiver, intentFilter);
声明一个广播
/*
* 接收个数量改变广播
*/
public class ShopDetailBroadcserReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("com.szx.YYY")) {
hanlder.sendEmptyMessage(0);
}
}
}
谁走进你的生命,是由命运决定,谁停留在你的生命中,却由你自己决定