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);
  }
}

}

 

posted @ 2013-10-26 16:43  sleepend  阅读(269)  评论(0编辑  收藏  举报