Successfully reported this slideshow.
Your SlideShare is downloading. ×

MDAD 6 - AIDL and Services

Ad

Android
AIDL and Services

Ad

Bibliography
1. Mark MURPHY, Beginning Android 2, Apress,
2010
– Capitolul 30
2. Lesson: Concurrency,
http://java.sun.com/...

Ad

Contents
• Services
– Events
– Events loop
– Start/Stop
– Communication
• AIDL
3

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Check these out next

1 of 23 Ad
1 of 23 Ad

More Related Content

MDAD 6 - AIDL and Services

  1. 1. Android AIDL and Services
  2. 2. Bibliography 1. Mark MURPHY, Beginning Android 2, Apress, 2010 – Capitolul 30 2. Lesson: Concurrency, http://java.sun.com/docs/books/tutorial/ess ential/concurrency/ 2
  3. 3. Contents • Services – Events – Events loop – Start/Stop – Communication • AIDL 3
  4. 4. Services • Android component • Special for processing • Runs in background • Process – Smaller pripority – More stable (in time) 4
  5. 5. Services Lifecycle 5
  6. 6. Service Implementation • Extends Service – Simple service • void onCreate (); • void onStart (Intent intent, int startID); • void onDestroy (); – Using AIDL • void onBind (Intent intent); • void onUnbind(); 6
  7. 7. Service lifecycle • Share the same thread with activities • Processing is not allowed within lifecycle functions 7
  8. 8. Service implementation 1. Extend Service – Implement functions – Create threads 2. Declare in manifest 3. Start / stop – startService (…) – stopService (…) 8
  9. 9. Example • Display one prime number each second – Service does not start automatically – Service does not stop automatically 9
  10. 10. NumerePrime - Service 10
  11. 11. NumerePrime – Actual thread 11
  12. 12. Start service Intent starter = new Intent (context, ServiceClass.class); context.startService (starter); 12
  13. 13. Stop service context.stopService (starter); stopSelf (); 13
  14. 14. AIDL • Android Interface Definition Language – RPC for Android • Connects the activities and services 14
  15. 15. Remote Procedure Call 15
  16. 16. AIDL • Similar to Java • Identical declaration • Limited variable types – primary (int, long, float, double, char, boolean) – String – List* – Map* – Special types * Needs to contain only AIDL specific types 16
  17. 17. Example… IserviciuFilme.aidl package pdm.film; interface IServiciuFilme { int numarFilme (); String titluFilm (int numar); String regizorFilm (int numar); } 17
  18. 18. AIDL => clasă • IServiciuFilme.aidl – IServiciuFilme.Stub • Abstract class containing the functions in the Interface 18
  19. 19. ListaFilme - Service 19
  20. 20. ListaFilme – the actual service 20
  21. 21. Connect Using AIDL 21
  22. 22. Connect Using AIDL 22
  23. 23. Questions 23

×