SlideShare a Scribd company logo
1 of 18
Android Service
Anjan Debnath
Foreground Service
• it always run in foreground.
• this can avoid service object being recycled by android
system when android os do not have enough resources.
• Android foreground service can be interacted by user
through notification.
Started Service
• Started services are those that are launched by other
application components like an Activity or a Broadcast
Receiver.
• They can run indefinitely in the background until stopped
or destroyed by the system to free up resources.
Bound Service
• Started services cannot return results/values or interact
with its starting component.
• Bound services on the other hand can send data to the
launching component (client).
IPC
• IPC means Inter Process communication where two
applications or processes will communicate with each
other by passing some data between them.
• On Android, one process cannot normally access
the memory of another process.
• In both cases, the system must provide a "channel" that
allows two processes to communicate.
• IPC with Messenger and Handler
• IPC with AIDL (Android Interface Definition
Language)
Messenger
• messages to be passed across process boundaries
between client (client component) and server (service).
AIDL
• AIDL allows you to define the programming interface that
both the client and service agree upon in order to
communicate with each other using interprocess
communication (IPC).
Compared to AIDL
• When you need to perform IPC, using a Messenger for
your interface is simpler than using AIDL,
because Messengerqueues all calls to the service.
• A pure AIDL interface sends simultaneous requests to
the service, which must then handle multi-threading.
• For most applications, the service doesn't need to
perform multi-threading, so using a Messengerallows the
service to handle one call at a time.
• If it's important that your service be multi-threaded,
use AIDL to define your interface.
When Use AIDL
• Using AIDL is necessary only if you allow clients from
different applications to access your service for IPC and
want to handle multithreading in your service.
• If you do not need to perform concurrent IPC across
different applications, you should create your interface
by implementing a Binder or,
• if you want to perform IPC, but do not need to handle
multithreading, implement your interface using a
Messenger.
Server Client App with
AIDL
Inter Process
Communication (IPC)
• AIDL service provides IPC.
• When any task completed service will send response to
activities that actually bound that service
Remote Procedural Call
RPC
• AIDL service also provides RPC.
• When Activity request for data, Service will response
back instantly.
Project Structure
IHotPotato is the main AIDL interface
HotPotatoService is the Private Remote Service
IPeer.aidl
• When PEER_CHANGED event found new MeshID then
we convert that to MeshPeer.
• MeshProvider will sent this MeshPeer as a callback to
HotPotato Service via IPeer.aidl
• Activity that wants to be notified when new Peer
discovered , will register this callback via
getPeerInfo(IPeer peer)
• When Service receive the callback it will send
response to bounded activity.
Idata.aidl
• When DATA_RECEIVED event found new Data then we
convert that to MeshData.
• MeshProvider will sent this MeshData as a callback to
HotPotato Service via IData.aidl
• Activity that wants to be notified when new Data received
, will register this callback via getData(IData data)
• When Service receive the callback it will send
response to bounded activity.
RPC methods
• From Activity if we want peers List then activity will make
a RPC call to AIDL service via getPeersLists().
• According to request Service will response back with
peer list.
• From activity if we want to send message then again
activity will make a RPC call with
sendMessage(MeshData data)
• If we want self peer from activity then make a RPC call
with getSelfPeer();
Q&A
Thanks

More Related Content

What's hot

Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
Utkarsh Mankad
 
Android telephony stack
Android telephony stackAndroid telephony stack
Android telephony stack
David Marques
 
Overview of Android binder IPC implementation
Overview of Android binder IPC implementationOverview of Android binder IPC implementation
Overview of Android binder IPC implementation
Chethan Pchethan
 

What's hot (20)

The Android graphics path, in depth
The Android graphics path, in depthThe Android graphics path, in depth
The Android graphics path, in depth
 
Android IPC Mechanism
Android IPC MechanismAndroid IPC Mechanism
Android IPC Mechanism
 
Android Booting Sequence
Android Booting SequenceAndroid Booting Sequence
Android Booting Sequence
 
Embedded Android : System Development - Part IV (Android System Services)
Embedded Android : System Development - Part IV (Android System Services)Embedded Android : System Development - Part IV (Android System Services)
Embedded Android : System Development - Part IV (Android System Services)
 
Parceable serializable
Parceable serializableParceable serializable
Parceable serializable
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
 
05 intent
05 intent05 intent
05 intent
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System Server
 
Android - Phone Calls
Android - Phone CallsAndroid - Phone Calls
Android - Phone Calls
 
Android telephony stack
Android telephony stackAndroid telephony stack
Android telephony stack
 
Android Architecture
Android ArchitectureAndroid Architecture
Android Architecture
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
An Introduction to the Android Framework -- a core architecture view from app...
An Introduction to the Android Framework -- a core architecture view from app...An Introduction to the Android Framework -- a core architecture view from app...
An Introduction to the Android Framework -- a core architecture view from app...
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Android Binder: Deep Dive
Android Binder: Deep DiveAndroid Binder: Deep Dive
Android Binder: Deep Dive
 
Scheduling in Android
Scheduling in AndroidScheduling in Android
Scheduling in Android
 
Explore Android Internals
Explore Android InternalsExplore Android Internals
Explore Android Internals
 
Overview of Android binder IPC implementation
Overview of Android binder IPC implementationOverview of Android binder IPC implementation
Overview of Android binder IPC implementation
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Android
AndroidAndroid
Android
 

Similar to Aidl service

Android intents, notification and broadcast recievers
Android intents, notification and broadcast recieversAndroid intents, notification and broadcast recievers
Android intents, notification and broadcast recievers
Utkarsh Mankad
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & Databases
Muhammad Sajid
 

Similar to Aidl service (20)

Android service
Android serviceAndroid service
Android service
 
Android Training (Services)
Android Training (Services)Android Training (Services)
Android Training (Services)
 
Android intents, notification and broadcast recievers
Android intents, notification and broadcast recieversAndroid intents, notification and broadcast recievers
Android intents, notification and broadcast recievers
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Displaying google maps in mobileapplication.pptx
Displaying google maps in mobileapplication.pptxDisplaying google maps in mobileapplication.pptx
Displaying google maps in mobileapplication.pptx
 
Android App Development - 08 Services
Android App Development - 08 ServicesAndroid App Development - 08 Services
Android App Development - 08 Services
 
Inter Process Communication (IPC) in Android
Inter Process Communication (IPC) in AndroidInter Process Communication (IPC) in Android
Inter Process Communication (IPC) in Android
 
Components of client server application
Components of client server applicationComponents of client server application
Components of client server application
 
Temporary selection of server in conventional client server
Temporary selection of server in conventional client serverTemporary selection of server in conventional client server
Temporary selection of server in conventional client server
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & Databases
 
Android Application Development
Android Application DevelopmentAndroid Application Development
Android Application Development
 
Andriod Lecture 8 A.pptx
Andriod Lecture 8 A.pptxAndriod Lecture 8 A.pptx
Andriod Lecture 8 A.pptx
 
Creating Android Services with Delphi and RAD Studio 10 Seattle
Creating Android Services with Delphi and RAD Studio 10 SeattleCreating Android Services with Delphi and RAD Studio 10 Seattle
Creating Android Services with Delphi and RAD Studio 10 Seattle
 
Android Development Tutorial
Android Development TutorialAndroid Development Tutorial
Android Development Tutorial
 
Basics 4
Basics   4Basics   4
Basics 4
 
Services in kubernetes-KnolX .pdf
Services in kubernetes-KnolX .pdfServices in kubernetes-KnolX .pdf
Services in kubernetes-KnolX .pdf
 
Alfresco Process Services (APS) and the Internet of Things
Alfresco Process Services (APS) and the Internet of ThingsAlfresco Process Services (APS) and the Internet of Things
Alfresco Process Services (APS) and the Internet of Things
 
Android Whats running in background
Android Whats running in backgroundAndroid Whats running in background
Android Whats running in background
 
Android101
Android101Android101
Android101
 
I44084954
I44084954I44084954
I44084954
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answers
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 

Aidl service

  • 2. Foreground Service • it always run in foreground. • this can avoid service object being recycled by android system when android os do not have enough resources. • Android foreground service can be interacted by user through notification.
  • 3. Started Service • Started services are those that are launched by other application components like an Activity or a Broadcast Receiver. • They can run indefinitely in the background until stopped or destroyed by the system to free up resources.
  • 4. Bound Service • Started services cannot return results/values or interact with its starting component. • Bound services on the other hand can send data to the launching component (client).
  • 5. IPC • IPC means Inter Process communication where two applications or processes will communicate with each other by passing some data between them. • On Android, one process cannot normally access the memory of another process. • In both cases, the system must provide a "channel" that allows two processes to communicate. • IPC with Messenger and Handler • IPC with AIDL (Android Interface Definition Language)
  • 6. Messenger • messages to be passed across process boundaries between client (client component) and server (service).
  • 7. AIDL • AIDL allows you to define the programming interface that both the client and service agree upon in order to communicate with each other using interprocess communication (IPC).
  • 8. Compared to AIDL • When you need to perform IPC, using a Messenger for your interface is simpler than using AIDL, because Messengerqueues all calls to the service. • A pure AIDL interface sends simultaneous requests to the service, which must then handle multi-threading. • For most applications, the service doesn't need to perform multi-threading, so using a Messengerallows the service to handle one call at a time. • If it's important that your service be multi-threaded, use AIDL to define your interface.
  • 9. When Use AIDL • Using AIDL is necessary only if you allow clients from different applications to access your service for IPC and want to handle multithreading in your service. • If you do not need to perform concurrent IPC across different applications, you should create your interface by implementing a Binder or, • if you want to perform IPC, but do not need to handle multithreading, implement your interface using a Messenger.
  • 10. Server Client App with AIDL
  • 11. Inter Process Communication (IPC) • AIDL service provides IPC. • When any task completed service will send response to activities that actually bound that service
  • 12. Remote Procedural Call RPC • AIDL service also provides RPC. • When Activity request for data, Service will response back instantly.
  • 13. Project Structure IHotPotato is the main AIDL interface HotPotatoService is the Private Remote Service
  • 14. IPeer.aidl • When PEER_CHANGED event found new MeshID then we convert that to MeshPeer. • MeshProvider will sent this MeshPeer as a callback to HotPotato Service via IPeer.aidl • Activity that wants to be notified when new Peer discovered , will register this callback via getPeerInfo(IPeer peer) • When Service receive the callback it will send response to bounded activity.
  • 15. Idata.aidl • When DATA_RECEIVED event found new Data then we convert that to MeshData. • MeshProvider will sent this MeshData as a callback to HotPotato Service via IData.aidl • Activity that wants to be notified when new Data received , will register this callback via getData(IData data) • When Service receive the callback it will send response to bounded activity.
  • 16. RPC methods • From Activity if we want peers List then activity will make a RPC call to AIDL service via getPeersLists(). • According to request Service will response back with peer list. • From activity if we want to send message then again activity will make a RPC call with sendMessage(MeshData data) • If we want self peer from activity then make a RPC call with getSelfPeer();
  • 17. Q&A