SlideShare una empresa de Scribd logo
1 de 9
Service MultiUni Trần Vũ Tất Bình
Tổng quan ,[object Object],[object Object],[object Object],[object Object]
Lifecycle – startService() onCreate() onStart() onDestroy() Service đang chạy Service được start lần đầu Service lại được yêu cầu start trong khi đã chạy rồi Bên ngoài gọi stopService() hoặc service tự stop
Lifecycle – startService() ,[object Object],[object Object],[object Object]
Lifecycle – bindService() onCreate() onBind() Service đang chạy Activity gọi bindService() để kết nối tới service Bên ngoài gọi unbindService() hoặc kết nối bị ngắt onUnbind() Service không còn kết nối với client nào nữa và cũng ko có context nào start service này onDestroy() Service còn chạy, client muốn kết nối với service onRebind() Lần trước unBind() với client này trả về  true
Lifecycle – bindService() ,[object Object],[object Object],[object Object]
Lifecycle ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Xem demo LocalService ,[object Object],[object Object],[object Object],[object Object]
Sử dụng service ,[object Object],[object Object],[object Object],[object Object],[object Object]

Más contenido relacionado

Destacado

Mobile programming
Mobile programming Mobile programming
Mobile programming Thinh Huynh
 
Slide bài giảng lập trình Android DTU - Phần 5 (Broadcastreceiver)
Slide bài giảng lập trình Android DTU - Phần 5 (Broadcastreceiver)Slide bài giảng lập trình Android DTU - Phần 5 (Broadcastreceiver)
Slide bài giảng lập trình Android DTU - Phần 5 (Broadcastreceiver)Techacademy Software
 
Bài 7: Toast – Dialog, ListView & Binding
Bài 7: Toast – Dialog, ListView & BindingBài 7: Toast – Dialog, ListView & Binding
Bài 7: Toast – Dialog, ListView & Bindinghoccungdoanhnghiep
 
Slide bài giảng lập trình Android DTU - Phần 4 (Activity)
Slide bài giảng lập trình Android DTU - Phần 4 (Activity)Slide bài giảng lập trình Android DTU - Phần 4 (Activity)
Slide bài giảng lập trình Android DTU - Phần 4 (Activity)Techacademy Software
 
Bài 4: Event handle, Action & Intent
Bài 4: Event handle, Action & IntentBài 4: Event handle, Action & Intent
Bài 4: Event handle, Action & Intenthoccungdoanhnghiep
 
Slide bài giảng lập trình Android DTU - Phần 1
Slide bài giảng lập trình Android DTU - Phần 1Slide bài giảng lập trình Android DTU - Phần 1
Slide bài giảng lập trình Android DTU - Phần 1Techacademy Software
 
Regular expression in javascript
Regular expression in javascriptRegular expression in javascript
Regular expression in javascriptToan Nguyen
 
Android location sensor programming
Android location sensor programmingAndroid location sensor programming
Android location sensor programmingPhuoc Nguyen
 
Android Nâng cao-Bài 3: Broadcast Receiver
Android Nâng cao-Bài 3: Broadcast ReceiverAndroid Nâng cao-Bài 3: Broadcast Receiver
Android Nâng cao-Bài 3: Broadcast ReceiverPhuoc Nguyen
 
Android Nâng cao-Bài 5:Notification Multiresolution Multilanguage
Android Nâng cao-Bài 5:Notification Multiresolution MultilanguageAndroid Nâng cao-Bài 5:Notification Multiresolution Multilanguage
Android Nâng cao-Bài 5:Notification Multiresolution MultilanguagePhuoc Nguyen
 
Android Nâng cao-Bài 6-Multi theme-adb tool-jUnit
Android Nâng cao-Bài 6-Multi theme-adb tool-jUnitAndroid Nâng cao-Bài 6-Multi theme-adb tool-jUnit
Android Nâng cao-Bài 6-Multi theme-adb tool-jUnitPhuoc Nguyen
 

Destacado (16)

Mobile programming
Mobile programming Mobile programming
Mobile programming
 
Slide bài giảng lập trình Android DTU - Phần 5 (Broadcastreceiver)
Slide bài giảng lập trình Android DTU - Phần 5 (Broadcastreceiver)Slide bài giảng lập trình Android DTU - Phần 5 (Broadcastreceiver)
Slide bài giảng lập trình Android DTU - Phần 5 (Broadcastreceiver)
 
Bài 7: Toast – Dialog, ListView & Binding
Bài 7: Toast – Dialog, ListView & BindingBài 7: Toast – Dialog, ListView & Binding
Bài 7: Toast – Dialog, ListView & Binding
 
Bài 6: Working with DATA
Bài 6: Working with DATABài 6: Working with DATA
Bài 6: Working with DATA
 
Slide bài giảng lập trình Android DTU - Phần 4 (Activity)
Slide bài giảng lập trình Android DTU - Phần 4 (Activity)Slide bài giảng lập trình Android DTU - Phần 4 (Activity)
Slide bài giảng lập trình Android DTU - Phần 4 (Activity)
 
Bài 8: ListView & Binding
Bài 8: ListView & BindingBài 8: ListView & Binding
Bài 8: ListView & Binding
 
Bài 4: Event handle, Action & Intent
Bài 4: Event handle, Action & IntentBài 4: Event handle, Action & Intent
Bài 4: Event handle, Action & Intent
 
Slide bài giảng lập trình Android DTU - Phần 1
Slide bài giảng lập trình Android DTU - Phần 1Slide bài giảng lập trình Android DTU - Phần 1
Slide bài giảng lập trình Android DTU - Phần 1
 
Regular expression in javascript
Regular expression in javascriptRegular expression in javascript
Regular expression in javascript
 
Android location sensor programming
Android location sensor programmingAndroid location sensor programming
Android location sensor programming
 
Android Nâng cao-Bài 3: Broadcast Receiver
Android Nâng cao-Bài 3: Broadcast ReceiverAndroid Nâng cao-Bài 3: Broadcast Receiver
Android Nâng cao-Bài 3: Broadcast Receiver
 
Android Nâng cao-Bài 5:Notification Multiresolution Multilanguage
Android Nâng cao-Bài 5:Notification Multiresolution MultilanguageAndroid Nâng cao-Bài 5:Notification Multiresolution Multilanguage
Android Nâng cao-Bài 5:Notification Multiresolution Multilanguage
 
Lanh dao va TPP
Lanh dao va TPPLanh dao va TPP
Lanh dao va TPP
 
Bai tap thuc hanh
Bai tap thuc hanhBai tap thuc hanh
Bai tap thuc hanh
 
Android Nâng cao-Bài 6-Multi theme-adb tool-jUnit
Android Nâng cao-Bài 6-Multi theme-adb tool-jUnitAndroid Nâng cao-Bài 6-Multi theme-adb tool-jUnit
Android Nâng cao-Bài 6-Multi theme-adb tool-jUnit
 
Lap trinh android – kiem tien ngay trong khi hoc
Lap trinh android – kiem tien ngay trong khi hocLap trinh android – kiem tien ngay trong khi hoc
Lap trinh android – kiem tien ngay trong khi hoc
 

IT120-6. Service

  • 1. Service MultiUni Trần Vũ Tất Bình
  • 2.
  • 3. Lifecycle – startService() onCreate() onStart() onDestroy() Service đang chạy Service được start lần đầu Service lại được yêu cầu start trong khi đã chạy rồi Bên ngoài gọi stopService() hoặc service tự stop
  • 4.
  • 5. Lifecycle – bindService() onCreate() onBind() Service đang chạy Activity gọi bindService() để kết nối tới service Bên ngoài gọi unbindService() hoặc kết nối bị ngắt onUnbind() Service không còn kết nối với client nào nữa và cũng ko có context nào start service này onDestroy() Service còn chạy, client muốn kết nối với service onRebind() Lần trước unBind() với client này trả về true
  • 6.
  • 7.
  • 8.
  • 9.

Notas del editor

  1. mong muốn = desire chạy nền = run in background
  2. Ngắt = disconnecetd
  3. nhất thiết = absolutely necessary vận hành = operate tính toán = compute đều đặn = regular kết quả khi nào người dùng cần thì mới xem = the results that the user needs to see