SlideShare una empresa de Scribd logo
1 de 19
Descargar para leer sin conexión
Android Service
Topics
• What is a Service?
• Service lifecycles
• Permissions
• Local services
• Remote services
What is a Service?
When a Service Used?
• Applications will need to run processes for a
long time without any intervention from the
user, or very rare interventions.
• These background processes need to keep
running even when the phone is being used for
other activities / tasks.
Two Types of Services
• Local service
> Not accessible from other applications
> Runs in the same process of the application that
starts it
• Remote service
> Accessible from other applications as well
> Exposes to other applications through AIDL (Android
Services Definition Language)
Service and Notification
• Service is a long lived component and does not
implement any user interface of its own.
> Typically a user interacts with a service through an
activity that has a UI.
• The service “notifies” the user in case of any
need for user intervention.
> Through the notification (such as status bar
notification), the service can give a user interface for
binding to the service or viewing the status of the
service or any other similar interaction with the
service.
What Facilities Service Provide?
• A facility for the application to tell the system
about something it wants to be doing in the
background (even when the user is not directly
interacting with the application).
> This corresponds to calls to Context.startService(),
which ask the system to schedule work for the
service, to be run until the service or someone else
explicitly stop it.
• A facility for an application to expose some of
its functionality to other applications.
> This corresponds to calls to Context.bindService(),
which allows a long-standing connection to be made
to the service in order to interact with it.
Binding to a Service
• Once a service has begun and is running in the
background, activities can “bind” to the service.
> In fact, if we want to bind to a service that has not
started, calling to bind could initiate the service.
Service Lifecycle
Starting a Service
• If someone calls Context.startService() then the
system will retrieve the service (creating it and
calling its onCreate() method if needed) and
then call its onStartCommand(Intent, int, int)
method with the arguments supplied by the
client.
• The service will at this point continue running
until Context.stopService() or stopSelf() is
called.
Modes of Operations
• For started services, there are two additional
major modes of operation they can decide to
run in, depending on the value they return from
onStartCommand():
> START_STICKY is used for services that are explicitly
started and stopped as needed,
> START_NOT_STICKY or START_REDELIVER_INTENT
are used for services that should only remain running
while processing any commands sent to them.
Getting a Connection to a Service
• Clients can also use Context.bindService() to
obtain a persistent connection to a service.
> This likewise creates the service if it is not already
running (calling onCreate() while doing so), but does
not call onStartCommand().
• The client will receive the IBinder object that
the service returns from its onBind(Intent)
method, allowing the client to then make calls
back to the service.
Permissions
Permissions
• Global access to a service can be enforced
when it is declared in its manifest's <service>
tag.
• By doing so, other applications will need to
declare a corresponding <uses-permission>
element in their own manifest to be able to
start, stop, or bind to the service.
• In addition, a service can protect individual IPC
calls into it with permissions, by calling the
checkCallingPermission(String) method before
executing the implementation of that call.
Local Service Sample
Local Service
• One of the most common uses of a Service is as
a secondary component running alongside
other parts of an application, in the same
process as the rest of the components.
> All components of an .apk run in the same process
unless explicitly stated otherwise, so this is a typical
situation.
• When used in this way, by assuming the
components are in the same process, you can
greatly simplify the interaction between them
> Clients of the service can simply cast the IBinder
they receive from it to a concrete class published by
the service.
Remote Messenger Service
Remote Messenger Service
• If you need to be able to write a Service that
can perform complicated communication with
clients in remote processes (beyond simply the
use of Context.startService to send commands
to it), then you can use the Messenger class
instead of writing full AIDL files.
Thank you

Más contenido relacionado

Destacado

Todo trabajo es temporal
Todo trabajo es temporalTodo trabajo es temporal
Todo trabajo es temporalAndroid UNAM
 
Android de la A a la Z Actividades ulises gonzalez
Android de la A a la Z   Actividades ulises gonzalezAndroid de la A a la Z   Actividades ulises gonzalez
Android de la A a la Z Actividades ulises gonzalezAndroid UNAM
 
Android de la A a la Z XML Ulises Gonzalez
Android de la A a la Z  XML Ulises GonzalezAndroid de la A a la Z  XML Ulises Gonzalez
Android de la A a la Z XML Ulises GonzalezAndroid UNAM
 
Curso Taller Android Procesado Imagen
Curso Taller Android Procesado ImagenCurso Taller Android Procesado Imagen
Curso Taller Android Procesado ImagenEmilio Aviles Avila
 
operaciones aritméticas usando
operaciones aritméticas  usando operaciones aritméticas  usando
operaciones aritméticas usando Sarahi Garcia Ruiz
 
ESTRUCTURA DE UN PROYECTO EN ANDROID STUDIO 2.2
ESTRUCTURA DE UN PROYECTO EN ANDROID STUDIO 2.2ESTRUCTURA DE UN PROYECTO EN ANDROID STUDIO 2.2
ESTRUCTURA DE UN PROYECTO EN ANDROID STUDIO 2.2Jacinto Cabrera Rodríguez
 
Desarrollo android - 6 - multimedia
Desarrollo android - 6 - multimediaDesarrollo android - 6 - multimedia
Desarrollo android - 6 - multimediaEmilio Aviles Avila
 
Intro. a Android Instituto Bosc de la Coma en Olot
Intro. a Android Instituto Bosc de la Coma en OlotIntro. a Android Instituto Bosc de la Coma en Olot
Intro. a Android Instituto Bosc de la Coma en Olothojalataverde
 
BDJ Team_Oct2015_pg_BADT
BDJ Team_Oct2015_pg_BADTBDJ Team_Oct2015_pg_BADT
BDJ Team_Oct2015_pg_BADTJulie Bissett
 
Interfaces increibles en Android
Interfaces increibles en AndroidInterfaces increibles en Android
Interfaces increibles en Androidjezabelink
 
Desarrollo en Android: Conceptos Básicos
Desarrollo en Android: Conceptos BásicosDesarrollo en Android: Conceptos Básicos
Desarrollo en Android: Conceptos BásicosGabriel Huecas
 
Sincronización de BD SQLite con MySQL en Android
Sincronización de BD SQLite con MySQL en AndroidSincronización de BD SQLite con MySQL en Android
Sincronización de BD SQLite con MySQL en AndroidMeison Chirinos
 
Education and Management of Diabetics
Education and Management of DiabeticsEducation and Management of Diabetics
Education and Management of DiabeticsDalia A. Hamdy
 
Diseño de interfaces móviles (UX y la arquitectura de software)
Diseño de interfaces móviles (UX y la arquitectura de software)Diseño de interfaces móviles (UX y la arquitectura de software)
Diseño de interfaces móviles (UX y la arquitectura de software)jezabelink
 
Bases de Datos en Android y Desarrollo de Aplicaciones Móviles Multiplataforma
Bases de Datos en Android y Desarrollo de Aplicaciones Móviles MultiplataformaBases de Datos en Android y Desarrollo de Aplicaciones Móviles Multiplataforma
Bases de Datos en Android y Desarrollo de Aplicaciones Móviles MultiplataformaUniversidad Autonoma de Chihuahua
 

Destacado (20)

Todo trabajo es temporal
Todo trabajo es temporalTodo trabajo es temporal
Todo trabajo es temporal
 
Android de la A a la Z Actividades ulises gonzalez
Android de la A a la Z   Actividades ulises gonzalezAndroid de la A a la Z   Actividades ulises gonzalez
Android de la A a la Z Actividades ulises gonzalez
 
Android de la A a la Z XML Ulises Gonzalez
Android de la A a la Z  XML Ulises GonzalezAndroid de la A a la Z  XML Ulises Gonzalez
Android de la A a la Z XML Ulises Gonzalez
 
Curso Taller Android Procesado Imagen
Curso Taller Android Procesado ImagenCurso Taller Android Procesado Imagen
Curso Taller Android Procesado Imagen
 
operaciones aritméticas usando
operaciones aritméticas  usando operaciones aritméticas  usando
operaciones aritméticas usando
 
Android: Interfaz de Usuario
Android: Interfaz de UsuarioAndroid: Interfaz de Usuario
Android: Interfaz de Usuario
 
ESTRUCTURA DE UN PROYECTO EN ANDROID STUDIO 2.2
ESTRUCTURA DE UN PROYECTO EN ANDROID STUDIO 2.2ESTRUCTURA DE UN PROYECTO EN ANDROID STUDIO 2.2
ESTRUCTURA DE UN PROYECTO EN ANDROID STUDIO 2.2
 
Desarrollo android - 6 - multimedia
Desarrollo android - 6 - multimediaDesarrollo android - 6 - multimedia
Desarrollo android - 6 - multimedia
 
Hola mundo
Hola mundoHola mundo
Hola mundo
 
Intro. a Android Instituto Bosc de la Coma en Olot
Intro. a Android Instituto Bosc de la Coma en OlotIntro. a Android Instituto Bosc de la Coma en Olot
Intro. a Android Instituto Bosc de la Coma en Olot
 
BDJ Team_Oct2015_pg_BADT
BDJ Team_Oct2015_pg_BADTBDJ Team_Oct2015_pg_BADT
BDJ Team_Oct2015_pg_BADT
 
Er. Anand Resume
Er. Anand ResumeEr. Anand Resume
Er. Anand Resume
 
Interfaces increibles en Android
Interfaces increibles en AndroidInterfaces increibles en Android
Interfaces increibles en Android
 
Game store app(2)
Game store app(2)Game store app(2)
Game store app(2)
 
Desarrollo en Android: Conceptos Básicos
Desarrollo en Android: Conceptos BásicosDesarrollo en Android: Conceptos Básicos
Desarrollo en Android: Conceptos Básicos
 
Sincronización de BD SQLite con MySQL en Android
Sincronización de BD SQLite con MySQL en AndroidSincronización de BD SQLite con MySQL en Android
Sincronización de BD SQLite con MySQL en Android
 
Iniciación a Android
Iniciación a AndroidIniciación a Android
Iniciación a Android
 
Education and Management of Diabetics
Education and Management of DiabeticsEducation and Management of Diabetics
Education and Management of Diabetics
 
Diseño de interfaces móviles (UX y la arquitectura de software)
Diseño de interfaces móviles (UX y la arquitectura de software)Diseño de interfaces móviles (UX y la arquitectura de software)
Diseño de interfaces móviles (UX y la arquitectura de software)
 
Bases de Datos en Android y Desarrollo de Aplicaciones Móviles Multiplataforma
Bases de Datos en Android y Desarrollo de Aplicaciones Móviles MultiplataformaBases de Datos en Android y Desarrollo de Aplicaciones Móviles Multiplataforma
Bases de Datos en Android y Desarrollo de Aplicaciones Móviles Multiplataforma
 

Similar a Android service

Services I.pptx
Services I.pptxServices I.pptx
Services I.pptxRiziX3
 
Android service and gcm
Android service and gcmAndroid service and gcm
Android service and gcmRan Zeller
 
Android App Development - 08 Services
Android App Development - 08 ServicesAndroid App Development - 08 Services
Android App Development - 08 ServicesDiego Grancini
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android DevelopmentOwain Lewis
 
Andriod Lecture 8 A.pptx
Andriod Lecture 8 A.pptxAndriod Lecture 8 A.pptx
Andriod Lecture 8 A.pptxfaiz324545
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & DatabasesMuhammad Sajid
 
Android intents, notification and broadcast recievers
Android intents, notification and broadcast recieversAndroid intents, notification and broadcast recievers
Android intents, notification and broadcast recieversUtkarsh Mankad
 
OutSystems community meetup 2018 11 service modules
OutSystems community meetup 2018 11 service modulesOutSystems community meetup 2018 11 service modules
OutSystems community meetup 2018 11 service modulesKurt Vandevelde
 
Outsystems community meetup 2018 11 service modules
Outsystems community meetup 2018 11 service modulesOutsystems community meetup 2018 11 service modules
Outsystems community meetup 2018 11 service modulesProvidit
 
Service-oriented architecture (SOA) is a method of software development that ...
Service-oriented architecture (SOA) is a method of software development that ...Service-oriented architecture (SOA) is a method of software development that ...
Service-oriented architecture (SOA) is a method of software development that ...ssuser0d0f881
 
Displaying google maps in mobileapplication.pptx
Displaying google maps in mobileapplication.pptxDisplaying google maps in mobileapplication.pptx
Displaying google maps in mobileapplication.pptxsanaiftikhar23
 
6. Microservices architecture.pptx
6. Microservices architecture.pptx6. Microservices architecture.pptx
6. Microservices architecture.pptxdatapro2
 
Intro to Microservices Architecture
Intro to Microservices ArchitectureIntro to Microservices Architecture
Intro to Microservices ArchitecturePeter Nijem
 
Testing Microservices
Testing MicroservicesTesting Microservices
Testing MicroservicesNagarro
 

Similar a Android service (20)

Services I.pptx
Services I.pptxServices I.pptx
Services I.pptx
 
Aidl service
Aidl serviceAidl service
Aidl service
 
Android service and gcm
Android service and gcmAndroid service and gcm
Android service and gcm
 
Android App Development - 08 Services
Android App Development - 08 ServicesAndroid App Development - 08 Services
Android App Development - 08 Services
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Andriod Lecture 8 A.pptx
Andriod Lecture 8 A.pptxAndriod Lecture 8 A.pptx
Andriod Lecture 8 A.pptx
 
Basics 4
Basics   4Basics   4
Basics 4
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & Databases
 
Android intents, notification and broadcast recievers
Android intents, notification and broadcast recieversAndroid intents, notification and broadcast recievers
Android intents, notification and broadcast recievers
 
JINI Technology
JINI TechnologyJINI Technology
JINI Technology
 
OutSystems community meetup 2018 11 service modules
OutSystems community meetup 2018 11 service modulesOutSystems community meetup 2018 11 service modules
OutSystems community meetup 2018 11 service modules
 
Outsystems community meetup 2018 11 service modules
Outsystems community meetup 2018 11 service modulesOutsystems community meetup 2018 11 service modules
Outsystems community meetup 2018 11 service modules
 
Service-oriented architecture (SOA) is a method of software development that ...
Service-oriented architecture (SOA) is a method of software development that ...Service-oriented architecture (SOA) is a method of software development that ...
Service-oriented architecture (SOA) is a method of software development that ...
 
Displaying google maps in mobileapplication.pptx
Displaying google maps in mobileapplication.pptxDisplaying google maps in mobileapplication.pptx
Displaying google maps in mobileapplication.pptx
 
6. Microservices architecture.pptx
6. Microservices architecture.pptx6. Microservices architecture.pptx
6. Microservices architecture.pptx
 
Testing microservices with rest assured
Testing microservices with rest assuredTesting microservices with rest assured
Testing microservices with rest assured
 
Android101
Android101Android101
Android101
 
Grails services
Grails servicesGrails services
Grails services
 
Intro to Microservices Architecture
Intro to Microservices ArchitectureIntro to Microservices Architecture
Intro to Microservices Architecture
 
Testing Microservices
Testing MicroservicesTesting Microservices
Testing Microservices
 

Más de Krazy Koder (20)

2310 b xd
2310 b xd2310 b xd
2310 b xd
 
2310 b xd
2310 b xd2310 b xd
2310 b xd
 
2310 b xd
2310 b xd2310 b xd
2310 b xd
 
2310 b xc
2310 b xc2310 b xc
2310 b xc
 
2310 b xb
2310 b xb2310 b xb
2310 b xb
 
2310 b 17
2310 b 172310 b 17
2310 b 17
 
2310 b 16
2310 b 162310 b 16
2310 b 16
 
2310 b 16
2310 b 162310 b 16
2310 b 16
 
2310 b 15
2310 b 152310 b 15
2310 b 15
 
2310 b 15
2310 b 152310 b 15
2310 b 15
 
2310 b 14
2310 b 142310 b 14
2310 b 14
 
2310 b 13
2310 b 132310 b 13
2310 b 13
 
2310 b 12
2310 b 122310 b 12
2310 b 12
 
2310 b 11
2310 b 112310 b 11
2310 b 11
 
2310 b 10
2310 b 102310 b 10
2310 b 10
 
2310 b 09
2310 b 092310 b 09
2310 b 09
 
2310 b 08
2310 b 082310 b 08
2310 b 08
 
2310 b 08
2310 b 082310 b 08
2310 b 08
 
2310 b 08
2310 b 082310 b 08
2310 b 08
 
2310 b 07
2310 b 072310 b 07
2310 b 07
 

Último

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Último (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Android service

  • 2. Topics • What is a Service? • Service lifecycles • Permissions • Local services • Remote services
  • 3. What is a Service?
  • 4. When a Service Used? • Applications will need to run processes for a long time without any intervention from the user, or very rare interventions. • These background processes need to keep running even when the phone is being used for other activities / tasks.
  • 5. Two Types of Services • Local service > Not accessible from other applications > Runs in the same process of the application that starts it • Remote service > Accessible from other applications as well > Exposes to other applications through AIDL (Android Services Definition Language)
  • 6. Service and Notification • Service is a long lived component and does not implement any user interface of its own. > Typically a user interacts with a service through an activity that has a UI. • The service “notifies” the user in case of any need for user intervention. > Through the notification (such as status bar notification), the service can give a user interface for binding to the service or viewing the status of the service or any other similar interaction with the service.
  • 7. What Facilities Service Provide? • A facility for the application to tell the system about something it wants to be doing in the background (even when the user is not directly interacting with the application). > This corresponds to calls to Context.startService(), which ask the system to schedule work for the service, to be run until the service or someone else explicitly stop it. • A facility for an application to expose some of its functionality to other applications. > This corresponds to calls to Context.bindService(), which allows a long-standing connection to be made to the service in order to interact with it.
  • 8. Binding to a Service • Once a service has begun and is running in the background, activities can “bind” to the service. > In fact, if we want to bind to a service that has not started, calling to bind could initiate the service.
  • 10. Starting a Service • If someone calls Context.startService() then the system will retrieve the service (creating it and calling its onCreate() method if needed) and then call its onStartCommand(Intent, int, int) method with the arguments supplied by the client. • The service will at this point continue running until Context.stopService() or stopSelf() is called.
  • 11. Modes of Operations • For started services, there are two additional major modes of operation they can decide to run in, depending on the value they return from onStartCommand(): > START_STICKY is used for services that are explicitly started and stopped as needed, > START_NOT_STICKY or START_REDELIVER_INTENT are used for services that should only remain running while processing any commands sent to them.
  • 12. Getting a Connection to a Service • Clients can also use Context.bindService() to obtain a persistent connection to a service. > This likewise creates the service if it is not already running (calling onCreate() while doing so), but does not call onStartCommand(). • The client will receive the IBinder object that the service returns from its onBind(Intent) method, allowing the client to then make calls back to the service.
  • 14. Permissions • Global access to a service can be enforced when it is declared in its manifest's <service> tag. • By doing so, other applications will need to declare a corresponding <uses-permission> element in their own manifest to be able to start, stop, or bind to the service. • In addition, a service can protect individual IPC calls into it with permissions, by calling the checkCallingPermission(String) method before executing the implementation of that call.
  • 16. Local Service • One of the most common uses of a Service is as a secondary component running alongside other parts of an application, in the same process as the rest of the components. > All components of an .apk run in the same process unless explicitly stated otherwise, so this is a typical situation. • When used in this way, by assuming the components are in the same process, you can greatly simplify the interaction between them > Clients of the service can simply cast the IBinder they receive from it to a concrete class published by the service.
  • 18. Remote Messenger Service • If you need to be able to write a Service that can perform complicated communication with clients in remote processes (beyond simply the use of Context.startService to send commands to it), then you can use the Messenger class instead of writing full AIDL files.