Android BroadcastReceiver 简介
2010-04-20 05:17:00 来源:WEB开发网核心提示:IntentFilter intentFilter = new IntentFilter();intentFilter.addAction(String);--为BroadcastReceiver指定action,使之用于接收同action的广播registerReceiver(BroadcastReceiver,in
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(String);--为BroadcastReceiver指定action,使之用于接收同action的广播registerReceiver(BroadcastReceiver,intentFilter);
一般:在onStart中注册,onStop中取消unregisterReceiver
发送广播消息:extends Service
指定广播目标Action:Intent Intent = new Intent(action-String)
--指定了此action的receiver会接收此广播
需传递参数(可选) putExtra();
发送:sendBroadcast(Intent);
Tags:Android BroadcastReceiver 简介
编辑录入:coldstar [复制链接] [打 印][]
更多精彩
赞助商链接