際際滷

際際滷Share a Scribd company logo
Service.
Service?
A Service is an application component that can perform long-
running operations in the background and does not provide a
user interface. Another application component can start a service
and it will continue to run in the background even if the user
switches to another application.
 .
 handle network transactions
 play music
 perform file I/O
 interact with a content provider
 蠍壱 焔
覦郁化 讌.
Service 2螳讌 .
Type 1.
語 螻, 蠏
れ 譯殊伎 殊
覦炎係殊企
 磯 螳
 .
Type 2.
覃襯 語
り, 企ゼ るジ
螻褐 語 貅
  
蟆 語 誤壱
伎 .
2螳讌 轟 覈 螳讌  .
襾殊 Deamon  覿仰~
Service Thread?
Service 覃 thread ろ 螻 覦炎係殊企 
螳  襦 ろ伎 蠍 覓語 覲 thread襯 牛伎
MediaPlayer螳豌企ゼ ろ. 蠏碁讌 朱 MediaPlayer螳 
  螳 覃伎 ′ 豬る
delay螳 覦 蟆.
螳蟆 れ 覺.
覲 Thread螳 殊,
覲 Thread螳 螻一 覦觜 豢螳朱
覃伎 るジ 覃伎  旧 給.
磯襦 覿襴螻 Stop り鍵.
stopService
12 service
Service 覲 Thread螳 .
A service runs in the main thread of its hosting processthe service
does not create its own thread and does not run in a
separate process (unless you specify otherwise). This means that, if
your service is going to do any CPU intensive work or blocking operations
(such as MP3 playback or networking), you should create a new
thread within the service to do that work. By using a
separate thread, you will reduce the risk of Application Not Responding
(ANR) errors and the application's main thread can remain
dedicated to user interaction with your activities.
觜る 讌  る ..
觜る 覈朱 讌襯 り碓 (stopService) 覃 
 襷豺覃 覃豢蟆 .
蠏碁る  蟆曙磯ゼ 螳.
Service螳 企朱 Thread襯 襷れ伎 5覿  覯 覃讌襯 
蟆 蟲 螻,  Service螳 start  .
 蟆曙一 App 螻 Home 覃伎朱 企蟇磯 るジ App 
 朱 讌朱 覃讌 蠑語 谿蟆 . Activity 蟯
螻  覲 蟲蠍 覓語.
企  覈伎, Service 覈譯手鍵襯 蠎 蠍 覦.
觜 return 螳
START_STICTY
覃覈襴覿譟煙企 蠍壱  ろ 螳襦 service襯 譬襭  service螳  
null Intent螳 願鹸 onStartCommand() 貊覦 螳 ろ.  蟆曙 null Intent襦 語 
蟆曙磯ゼ 豌襴伎 .
)   襦蠏碁 蟆曙, 覦炎係殊企  螻 蟆曙.
START_NOT_STICTY
 蟆曙磯 襦語り 螳襦 譬襭 蟆曙  讌 螻 譬襭 襦 蟆 . 
 企 覈轟 豌襴蠍   觜れ 一. 企 觜るれ 覲危 企 覈
轟 豌襴  stopSelf襯 伎 譬襭 蟆曙郁 れ.
) App 一危 觜 蟆曙一, 襴 蟆渚  れ  讌 螻 殊 蠍一.
START_REDELIVER_INTENT
 蟆曙一 襦語り 螳襦 譬襭 蟆曙 Intent螳 れ  . , 
 谿襦   譬襭讌 朱 service  讌 給. 覦 ろ伎 
 service 企轟
Service れ 語
startService 一 語
ろ 蟆郁骸
IntentService朱 蟆 伎.
Service朱 蟆 UI螳  れ  蟆企手  伎手鍵襯 讌襷,
覃語襯  覦 襷る 豌襴襯  螳 .
企ゼ 伎, 覃讌襯 覦  襷   蠍 伎
Thread 覃讌螳 れ伎る 蟆 覈磯螻, れ伎  豌襴襯 伎
讌. (願 android 襷 る handler 手  覿覿螻 
.)
企 蟆 覲襦 蟲  蟆 覯蟇磯  給. 企ゼ 
蟆 覈 蟲  蟆 IntentService.
覃讌 (Intent) 覦 豌襴 襯 豢. 蟲譟磯 れ 伎 谿瑚
IntentService Sample.
BroadCastReceiver 襦 蟲 螳.
蟯 谿瑚: http://mobile.tutsplus.com/tutorials/android/android-fundamentals-intentservice-basics/
Receiver 10 豐伎  襷豎 . 蠏碁蠍一  伎 譴 IntentService 
BroadcastReceiver襯  螳ロ    襷 襦伎   蠎 譯殊
豢豌: http://arabiannight.tistory.com/247
Ad

Recommended

PDF
06 activity stack and back, flag
伎 豕
PDF
13 service 譬
伎 豕
PDF
[NEXT] 覃 螳煙 襦企 襷り鍵 - ろ語 襴渚 蟲譟磯 覲蟆
YoungSu Son
PPTX
04 襦企 襦蠏碁 蟲譟
Wanbok Choi
PDF
02 activity.lifecycle
伎 豕
PPTX
Android 蠍一螳譬 襴貂伎 蟲譟
Sangon Lee
PPTX
襦企App螳覦 10.activity一危一′ thread
DaeHee Jang
PDF
Wot(daliworks) 20131113
伎 豕
PDF
NIPA SW Insight Report '13.08
伎 豕
PDF
Agile Spirit Base On The Book "Agile Samuari"
伎 豕
PDF
Uml intro 1
伎 豕
PDF
Uml intro 0
伎 豕
PDF
21 application and_network_status
伎 豕
PDF
20 handler and_async_task
伎 豕
PDF
18 襦企 襴ろ碁薫_レ
伎 豕
PDF
19 襷 view 襷り鍵
伎 豕
PDF
17 adapter view & db
伎 豕
PDF
16 一危 リ骸
伎 豕
PDF
15 content provider
伎 豕
PDF
14 broad castreceiver
伎 豕
PDF
11 tablet 螳企
伎 豕
PDF
10 view orientation_change
伎 豕
PDF
09 android keyboard & layout
伎 豕
PDF
08 fragment 觚襴
伎 豕
PDF
08 font size
伎 豕
PDF
07 れ device__覦覯
伎 豕
PDF
05 pending intent
伎 豕
PDF
04 activity螳 語蠍 & intent
伎 豕

More Related Content

More from 伎 豕 (20)

PDF
NIPA SW Insight Report '13.08
伎 豕
PDF
Agile Spirit Base On The Book "Agile Samuari"
伎 豕
PDF
Uml intro 1
伎 豕
PDF
Uml intro 0
伎 豕
PDF
21 application and_network_status
伎 豕
PDF
20 handler and_async_task
伎 豕
PDF
18 襦企 襴ろ碁薫_レ
伎 豕
PDF
19 襷 view 襷り鍵
伎 豕
PDF
17 adapter view & db
伎 豕
PDF
16 一危 リ骸
伎 豕
PDF
15 content provider
伎 豕
PDF
14 broad castreceiver
伎 豕
PDF
11 tablet 螳企
伎 豕
PDF
10 view orientation_change
伎 豕
PDF
09 android keyboard & layout
伎 豕
PDF
08 fragment 觚襴
伎 豕
PDF
08 font size
伎 豕
PDF
07 れ device__覦覯
伎 豕
PDF
05 pending intent
伎 豕
PDF
04 activity螳 語蠍 & intent
伎 豕
NIPA SW Insight Report '13.08
伎 豕
Agile Spirit Base On The Book "Agile Samuari"
伎 豕
Uml intro 1
伎 豕
Uml intro 0
伎 豕
21 application and_network_status
伎 豕
20 handler and_async_task
伎 豕
18 襦企 襴ろ碁薫_レ
伎 豕
19 襷 view 襷り鍵
伎 豕
17 adapter view & db
伎 豕
16 一危 リ骸
伎 豕
15 content provider
伎 豕
14 broad castreceiver
伎 豕
11 tablet 螳企
伎 豕
10 view orientation_change
伎 豕
09 android keyboard & layout
伎 豕
08 fragment 觚襴
伎 豕
08 font size
伎 豕
07 れ device__覦覯
伎 豕
05 pending intent
伎 豕
04 activity螳 語蠍 & intent
伎 豕

12 service

  • 2. Service? A Service is an application component that can perform long- running operations in the background and does not provide a user interface. Another application component can start a service and it will continue to run in the background even if the user switches to another application. . handle network transactions play music perform file I/O interact with a content provider 蠍壱 焔 覦郁化 讌.
  • 3. Service 2螳讌 . Type 1. 語 螻, 蠏 れ 譯殊伎 殊 覦炎係殊企 磯 螳 . Type 2. 覃襯 語 り, 企ゼ るジ 螻褐 語 貅 蟆 語 誤壱 伎 . 2螳讌 轟 覈 螳讌 .
  • 4. 襾殊 Deamon 覿仰~
  • 5. Service Thread? Service 覃 thread ろ 螻 覦炎係殊企 螳 襦 ろ伎 蠍 覓語 覲 thread襯 牛伎 MediaPlayer螳豌企ゼ ろ. 蠏碁讌 朱 MediaPlayer螳 螳 覃伎 ′ 豬る delay螳 覦 蟆.
  • 6. 螳蟆 れ 覺. 覲 Thread螳 殊, 覲 Thread螳 螻一 覦觜 豢螳朱 覃伎 るジ 覃伎 旧 給.
  • 7. 磯襦 覿襴螻 Stop り鍵. stopService
  • 9. Service 覲 Thread螳 . A service runs in the main thread of its hosting processthe service does not create its own thread and does not run in a separate process (unless you specify otherwise). This means that, if your service is going to do any CPU intensive work or blocking operations (such as MP3 playback or networking), you should create a new thread within the service to do that work. By using a separate thread, you will reduce the risk of Application Not Responding (ANR) errors and the application's main thread can remain dedicated to user interaction with your activities.
  • 10. 觜る 讌 る .. 觜る 覈朱 讌襯 り碓 (stopService) 覃 襷豺覃 覃豢蟆 . 蠏碁る 蟆曙磯ゼ 螳. Service螳 企朱 Thread襯 襷れ伎 5覿 覯 覃讌襯 蟆 蟲 螻, Service螳 start . 蟆曙一 App 螻 Home 覃伎朱 企蟇磯 るジ App 朱 讌朱 覃讌 蠑語 谿蟆 . Activity 蟯 螻 覲 蟲蠍 覓語. 企 覈伎, Service 覈譯手鍵襯 蠎 蠍 覦.
  • 11. 觜 return 螳 START_STICTY 覃覈襴覿譟煙企 蠍壱 ろ 螳襦 service襯 譬襭 service螳 null Intent螳 願鹸 onStartCommand() 貊覦 螳 ろ. 蟆曙 null Intent襦 語 蟆曙磯ゼ 豌襴伎 . ) 襦蠏碁 蟆曙, 覦炎係殊企 螻 蟆曙. START_NOT_STICTY 蟆曙磯 襦語り 螳襦 譬襭 蟆曙 讌 螻 譬襭 襦 蟆 . 企 覈轟 豌襴蠍 觜れ 一. 企 觜るれ 覲危 企 覈 轟 豌襴 stopSelf襯 伎 譬襭 蟆曙郁 れ. ) App 一危 觜 蟆曙一, 襴 蟆渚 れ 讌 螻 殊 蠍一. START_REDELIVER_INTENT 蟆曙一 襦語り 螳襦 譬襭 蟆曙 Intent螳 れ . , 谿襦 譬襭讌 朱 service 讌 給. 覦 ろ伎 service 企轟
  • 12. Service れ 語 startService 一 語 ろ 蟆郁骸
  • 13. IntentService朱 蟆 伎. Service朱 蟆 UI螳 れ 蟆企手 伎手鍵襯 讌襷, 覃語襯 覦 襷る 豌襴襯 螳 . 企ゼ 伎, 覃讌襯 覦 襷 蠍 伎 Thread 覃讌螳 れ伎る 蟆 覈磯螻, れ伎 豌襴襯 伎 讌. (願 android 襷 る handler 手 覿覿螻 .) 企 蟆 覲襦 蟲 蟆 覯蟇磯 給. 企ゼ 蟆 覈 蟲 蟆 IntentService. 覃讌 (Intent) 覦 豌襴 襯 豢. 蟲譟磯 れ 伎 谿瑚
  • 14. IntentService Sample. BroadCastReceiver 襦 蟲 螳. 蟯 谿瑚: http://mobile.tutsplus.com/tutorials/android/android-fundamentals-intentservice-basics/ Receiver 10 豐伎 襷豎 . 蠏碁蠍一 伎 譴 IntentService BroadcastReceiver襯 螳ロ 襷 襦伎 蠎 譯殊