othi
gbutreceivea
dreacttobroadcasta
ou
ceme
tsMa
ybroadcastsorigi
atei
systemcodeforexamplea
ou
ceme
tsthatthetimezo
ehascha
gedthatthebatteryislowthatapicturehasbee
take
orthattheusercha
gedala
guageprefere
ceApplicatio
sca
alsoi
itiatebroadcastsforexampletoletotherapplicatio
sk
owthatsomedatahasbee
dow
loadedtothedevicea
disavailableforthemtouseA
applicatio
ca
havea
y
umberofbroadcastreceiverstorespo
dtoa
ya
ou
ceme
tsitco
sidersimporta
tAllreceiversexte
dtheBroadcastReceiverbaseclassBroadcastreceiversdo
otdisplayauseri
terfaceHowevertheymaystarta
activityi
respo
setothei
formatio
theyreceiveortheymayusetheNotificatio
Ma
agertoalerttheuserNotificatio
sca
gettheusersatte
tio
i
variouswaysflashi
gthebacklightvibrati
gthedeviceplayi
gasou
da
dsoo
Theytypicallyplaceapersiste
tico
i
thestatusbarwhichusersca
ope
togetthe3:Broadcastreceiver
broadcastreceiver是一个与注于接收广播通知信息并做出相应处理的组件。许多广播是由系统代码产生的例如通知时区改变、电池电量低、拍摄了一张照片或者用户改变了语言选项。应用程序也可以发起广播例如通知其它应用程序一些数据已经下载到设备上并处于可用状态。一个应用程序可以拥有任意数量的broadcastreceiver以对所有它认为重要的通知信息予以响应。所有的receiver均继承自BroadcastReceiver基类。broadcastreceiver没有用户界面。然而它们可以启动一个activity来响应它们收到的信息或者也可以使用Notificatio
Ma
ager来通知用户。通知可以用多种方
共21页第2页
f式来吸引用户的注意力──闪动背光灯、震动设备、播放声音等等。通知一般是在状态栏上放一个持续的图标用户可以打开它并获取消息。Co
te
tprovidersAco
te
tprovidermakesaspecificsetoftheapplicatio
sdataavailabletootherapplicatio
sThedataca
bestoredi
thefilesystemi
a
SQLitedatabaseori
a
yotherma
erthatmakesse
seTheco
te
tproviderexte
dstheCo
te
tProviderbaseclasstoimpleme
tasta
dardsetofmethodsthate
ableotherapplicatio
storetrievea
dstoredataofthetypeitco
trolsHoweverapplicatio
sdo
otcallthesemethodsdirectlyRathertheyuseaCo
te
tResolverobjecta
dcallitsmethodsi
steadACo
te
tResolverca
talktoa
yco
te
tprovideritcooperateswiththeprovidertoma
agea
yi
terprocesscommu
icatio
thatsi
volvedSeetheseparateCo
te
tProvidersdocume
tformorei
formatio
o
usi
gco
te
tprovidersWhe
evertheresarequestthatshouldbeha
dledbyaparticularcompo
e
tA
droidmakessurethattheapplicatio
processofthecompo
e
tisru
i
gstarti
gitif
ecessarya
dthata
appropriatei
sta
cer