WEB开发网
开发学院手机开发Android 开发 Android BroadcastReceiver 简介 阅读

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

上一页  1 2 

Tags:Android BroadcastReceiver 简介

编辑录入:coldstar [复制链接] [打 印]
赞助商链接