5.BroadcastReceiver知识点总结

来源:互联网 发布:澳门网络真人博客官网 编辑:程序博客网 时间:2024/06/08 01:54
1.请描述一下BroadcastReceiver    有很多广播接收者 ,系统已经实现了.    广播分两种 有序广播    无序广播    指定接收者的广播 .  是不可以被拦截掉的      <intent-filter android:priority="1000">    <action android:name="android.provider.Telephony.SMS_RECEIVED"/>    </intent-filter>    abortBroadcast();    用于接收系统的广播通知, 系统会有很多sd卡挂载,手机重启,广播通知,低电量,来电,来短信等….    有些应用通过这些广播启动后台服务, 避免被杀死    电量改变广播, 必须动态注册    来获取短信到来的广播, 根据黑名单来判断是否拦截该短信.    画画板生成图片后,发送一个sd挂载的通知,通知系统的gallery去获取到新的图片.    Intent intent = new Intent(Intent.ACTION_MEDIA_MOUNTED,Uri.parse("file://"+Environment.getExternalStorageDirectory()));    sendBroadcast(intent);    可以作为组件间通信工具. EventBus2.在manifest和代码中如何注册和使用broadcastreceiver 。    设置广播接收者的优先级,设置广播接受者的action名字 等…    详细见工程代码.         <intent-filter android:priority="1000">           <action android:name="android.intent.action.NEW_OUTGOING_CALL"/>                  </intent-filter>        </receiver>        <receiver android:name=".SmsReceiver">            <intent-filter android:priority="1000">                <action android:name="android.provider.Telephony.SMS_RECEIVED"/>            </intent-filter>        </receiver>        <receiver android:name=".BootCompleteReceiver">            <intent-filter >                <action android:name="android.intent.action.BOOT_COMPLETED" />                      </intent-filter>        </receiver>
0 0
原创粉丝点击