BroadcastReceiver自学笔记

1. 使用步骤:

   1.1 声明Intent

Intent intent = new Intent("name");------静态常用

IntentFilter filter = new IntentFilter("name");--------动态常用

   1.2 注册

    1.3 接收:利用action或者Bundle

  在OnReceive()中,接收信息

    String action = intent.getAction();

    Bundle bundle = intent.getExtras();

2. 注册方式:

静态-在XML中注册过滤器

动态-在Activity的对应生命周期的函数里,注册和解除注册,要成对出现

3. 生命周期:OnReceive()

posted @ 2014-09-30 08:52  Matrix_Ran  阅读(179)  评论(0编辑  收藏  举报