SlideShare ist ein Scribd-Unternehmen logo
1 von 21
Downloaden Sie, um offline zu lesen
Android Service and GCM
A service is a component which runs in
the background without direct interaction
with the user. As the service has no user
interface, it is not bound to the lifecycle
of an activity.
Services are used for repetitive and
potentially long running operations, i.e.,
Internet downloads, checking for new
data
Android service and gcm
Defining custom services
A service needs to be declared in the
AndroidManifest.xml file
Android service and gcm
The implementing class must extend
the Service class or one of its
subclasses.
Android service and gcm
An Android component (service,
receiver, activity) can trigger the
execution of a service via the
startService(intent) method
If the startService(intent) method is
called and the service is not yet
running, the service object is created
and the onCreate() method of the
service is called.
Once the service is started, the
onStartCommand(intent) method in
the service is called. It passes in the
Intent object from the startService
(intent) call.
If startService(intent) is called while
the service is running, its
onStartCommand() is also called.
Therefore your service needs to be
prepared that onStartCommand()
can be called several times.
You stop a service via the
stopService() method. No matter how
frequently you called the startService
(intent) method, one call to the
stopService() method stops the
service
A service can terminate itself by
calling the stopSelf() method. This is
typically done if the service finishes
its work.
Services and background
By default, a service runs in the same
process as the main thread of the
application.
Therefore,you need to use asynchronous
processing in the service to perform
resource intensive tasks in the
background.
IntentService is a base class for Services
that handle asynchronous requests on
demand. Clients send requests through
startService(Intent) calls; the service is
started as needed, and stops itself when
it runs out of work.
Declares a broadcast receiver as one of
the application's components. Broadcast
receivers enable applications to receive
intents that are broadcast by the system
or by other applications, even when other
components of the application are not
running.
Receivers
GCM Example

Weitere ähnliche Inhalte

Andere mochten auch

Las tics en la sociedad
Las tics en la sociedadLas tics en la sociedad
Las tics en la sociedadgerardo tec
 
Wild Heart Posters
Wild Heart PostersWild Heart Posters
Wild Heart PostersJen Rabe
 
Gcm presentation
Gcm presentationGcm presentation
Gcm presentationNiraj Singh
 
Google cloud messaging
Google cloud messagingGoogle cloud messaging
Google cloud messagingAmardeep Vijay
 
Introduction to google cloud messaging in android
Introduction to google cloud messaging in androidIntroduction to google cloud messaging in android
Introduction to google cloud messaging in androidRIA RUI Society
 
Google Cloud Messaging
Google Cloud Messaging Google Cloud Messaging
Google Cloud Messaging Sandip Jadhav
 
Google Cloud Messaging
Google Cloud MessagingGoogle Cloud Messaging
Google Cloud MessagingArvind Devaraj
 
Google Cloud Messaging for Android
Google Cloud Messaging for AndroidGoogle Cloud Messaging for Android
Google Cloud Messaging for Androidedilsonmendes
 

Andere mochten auch (9)

Las tics en la sociedad
Las tics en la sociedadLas tics en la sociedad
Las tics en la sociedad
 
Wild Heart Posters
Wild Heart PostersWild Heart Posters
Wild Heart Posters
 
Gcm presentation
Gcm presentationGcm presentation
Gcm presentation
 
Google cloud messaging
Google cloud messagingGoogle cloud messaging
Google cloud messaging
 
Introduction to google cloud messaging in android
Introduction to google cloud messaging in androidIntroduction to google cloud messaging in android
Introduction to google cloud messaging in android
 
Google Cloud Messaging
Google Cloud Messaging Google Cloud Messaging
Google Cloud Messaging
 
Google Cloud Messaging
Google Cloud MessagingGoogle Cloud Messaging
Google Cloud Messaging
 
Google Cloud Messaging for Android
Google Cloud Messaging for AndroidGoogle Cloud Messaging for Android
Google Cloud Messaging for Android
 
Google Cloud Messaging
Google Cloud Messaging Google Cloud Messaging
Google Cloud Messaging
 

Ähnlich wie Android service and gcm

Android service, aidl - day 1
Android service, aidl - day 1Android service, aidl - day 1
Android service, aidl - day 1Utkarsh Mankad
 
Services I.pptx
Services I.pptxServices I.pptx
Services I.pptxRiziX3
 
Android intents, notification and broadcast recievers
Android intents, notification and broadcast recieversAndroid intents, notification and broadcast recievers
Android intents, notification and broadcast recieversUtkarsh Mankad
 
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxxMAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx34ShreyaChauhan
 
Android App Development - 08 Services
Android App Development - 08 ServicesAndroid App Development - 08 Services
Android App Development - 08 ServicesDiego Grancini
 
Fundamentals & Services
Fundamentals & ServicesFundamentals & Services
Fundamentals & ServicesJetti Chowdary
 
Android Service Intro
Android Service IntroAndroid Service Intro
Android Service IntroJintin Lin
 
Day 15: Working in Background
Day 15: Working in BackgroundDay 15: Working in Background
Day 15: Working in BackgroundAhsanul Karim
 
Android broadcast receiver tutorial
Android broadcast receiver   tutorialAndroid broadcast receiver   tutorial
Android broadcast receiver tutorialmaamir farooq
 
Android broadcast receiver tutorial
Android broadcast receiver  tutorialAndroid broadcast receiver  tutorial
Android broadcast receiver tutorialmaamir farooq
 
Android - Background operation
Android - Background operationAndroid - Background operation
Android - Background operationMatteo Bonifazi
 
Android Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAndroid Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAhsanul Karim
 
How to integrate flurry in android
How to integrate flurry in androidHow to integrate flurry in android
How to integrate flurry in androidadityakumar2080
 
Android BroadcastReceiver - How to start a service using BroadcastReceiver
Android BroadcastReceiver - How to start a service using BroadcastReceiverAndroid BroadcastReceiver - How to start a service using BroadcastReceiver
Android BroadcastReceiver - How to start a service using BroadcastReceiverSriSankeerth Reddy
 
Inter Process Communication (IPC) in Android
Inter Process Communication (IPC) in AndroidInter Process Communication (IPC) in Android
Inter Process Communication (IPC) in AndroidMalwinder Singh
 

Ähnlich wie Android service and gcm (20)

Android service, aidl - day 1
Android service, aidl - day 1Android service, aidl - day 1
Android service, aidl - day 1
 
Services I.pptx
Services I.pptxServices I.pptx
Services I.pptx
 
Android service
Android serviceAndroid service
Android service
 
Android intents, notification and broadcast recievers
Android intents, notification and broadcast recieversAndroid intents, notification and broadcast recievers
Android intents, notification and broadcast recievers
 
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxxMAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
 
Android App Development - 08 Services
Android App Development - 08 ServicesAndroid App Development - 08 Services
Android App Development - 08 Services
 
Fundamentals & Services
Fundamentals & ServicesFundamentals & Services
Fundamentals & Services
 
Android Service Intro
Android Service IntroAndroid Service Intro
Android Service Intro
 
Day 15: Working in Background
Day 15: Working in BackgroundDay 15: Working in Background
Day 15: Working in Background
 
Android broadcast receiver tutorial
Android broadcast receiver   tutorialAndroid broadcast receiver   tutorial
Android broadcast receiver tutorial
 
Android broadcast receiver tutorial
Android broadcast receiver  tutorialAndroid broadcast receiver  tutorial
Android broadcast receiver tutorial
 
Android101
Android101Android101
Android101
 
Android Services
Android ServicesAndroid Services
Android Services
 
Android Whats running in background
Android Whats running in backgroundAndroid Whats running in background
Android Whats running in background
 
Android - Background operation
Android - Background operationAndroid - Background operation
Android - Background operation
 
Android Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAndroid Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver Tutorial
 
How to integrate flurry in android
How to integrate flurry in androidHow to integrate flurry in android
How to integrate flurry in android
 
Unit2
Unit2Unit2
Unit2
 
Android BroadcastReceiver - How to start a service using BroadcastReceiver
Android BroadcastReceiver - How to start a service using BroadcastReceiverAndroid BroadcastReceiver - How to start a service using BroadcastReceiver
Android BroadcastReceiver - How to start a service using BroadcastReceiver
 
Inter Process Communication (IPC) in Android
Inter Process Communication (IPC) in AndroidInter Process Communication (IPC) in Android
Inter Process Communication (IPC) in Android
 

Kürzlich hochgeladen

Nodal seismic construction requirements.pptx
Nodal seismic construction requirements.pptxNodal seismic construction requirements.pptx
Nodal seismic construction requirements.pptxwendy cai
 
me3493 manufacturing technology unit 1 Part A
me3493 manufacturing technology unit 1 Part Ame3493 manufacturing technology unit 1 Part A
me3493 manufacturing technology unit 1 Part Akarthi keyan
 
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....santhyamuthu1
 
Technology Features of Apollo HDD Machine, Its Technical Specification with C...
Technology Features of Apollo HDD Machine, Its Technical Specification with C...Technology Features of Apollo HDD Machine, Its Technical Specification with C...
Technology Features of Apollo HDD Machine, Its Technical Specification with C...Apollo Techno Industries Pvt Ltd
 
The relationship between iot and communication technology
The relationship between iot and communication technologyThe relationship between iot and communication technology
The relationship between iot and communication technologyabdulkadirmukarram03
 
Clutches and brkesSelect any 3 position random motion out of real world and d...
Clutches and brkesSelect any 3 position random motion out of real world and d...Clutches and brkesSelect any 3 position random motion out of real world and d...
Clutches and brkesSelect any 3 position random motion out of real world and d...sahb78428
 
Transforming Process Safety Management: Challenges, Benefits, and Transition ...
Transforming Process Safety Management: Challenges, Benefits, and Transition ...Transforming Process Safety Management: Challenges, Benefits, and Transition ...
Transforming Process Safety Management: Challenges, Benefits, and Transition ...soginsider
 
EPE3163_Hydro power stations_Unit2_Lect2.pptx
EPE3163_Hydro power stations_Unit2_Lect2.pptxEPE3163_Hydro power stations_Unit2_Lect2.pptx
EPE3163_Hydro power stations_Unit2_Lect2.pptxJoseeMusabyimana
 
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...Sean Meyn
 
Best-NO1 Best Rohani Amil In Lahore Kala Ilam In Lahore Kala Jadu Amil In Lah...
Best-NO1 Best Rohani Amil In Lahore Kala Ilam In Lahore Kala Jadu Amil In Lah...Best-NO1 Best Rohani Amil In Lahore Kala Ilam In Lahore Kala Jadu Amil In Lah...
Best-NO1 Best Rohani Amil In Lahore Kala Ilam In Lahore Kala Jadu Amil In Lah...Amil baba
 
Test of Significance of Large Samples for Mean = µ.pptx
Test of Significance of Large Samples for Mean = µ.pptxTest of Significance of Large Samples for Mean = µ.pptx
Test of Significance of Large Samples for Mean = µ.pptxHome
 
A Seminar on Electric Vehicle Software Simulation
A Seminar on Electric Vehicle Software SimulationA Seminar on Electric Vehicle Software Simulation
A Seminar on Electric Vehicle Software SimulationMohsinKhanA
 
ASME BPVC 2023 Section I para leer y entender
ASME BPVC 2023 Section I para leer y entenderASME BPVC 2023 Section I para leer y entender
ASME BPVC 2023 Section I para leer y entenderjuancarlos286641
 
Basic Principle of Electrochemical Sensor
Basic Principle of  Electrochemical SensorBasic Principle of  Electrochemical Sensor
Basic Principle of Electrochemical SensorTanvir Moin
 
Design of Clutches and Brakes in Design of Machine Elements.pptx
Design of Clutches and Brakes in Design of Machine Elements.pptxDesign of Clutches and Brakes in Design of Machine Elements.pptx
Design of Clutches and Brakes in Design of Machine Elements.pptxYogeshKumarKJMIT
 
Phase noise transfer functions.pptx
Phase noise transfer      functions.pptxPhase noise transfer      functions.pptx
Phase noise transfer functions.pptxSaiGouthamSunkara
 

Kürzlich hochgeladen (20)

Nodal seismic construction requirements.pptx
Nodal seismic construction requirements.pptxNodal seismic construction requirements.pptx
Nodal seismic construction requirements.pptx
 
計劃趕得上變化
計劃趕得上變化計劃趕得上變化
計劃趕得上變化
 
Lecture 2 .pdf
Lecture 2                           .pdfLecture 2                           .pdf
Lecture 2 .pdf
 
me3493 manufacturing technology unit 1 Part A
me3493 manufacturing technology unit 1 Part Ame3493 manufacturing technology unit 1 Part A
me3493 manufacturing technology unit 1 Part A
 
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
 
Présentation IIRB 2024 Marine Cordonnier.pdf
Présentation IIRB 2024 Marine Cordonnier.pdfPrésentation IIRB 2024 Marine Cordonnier.pdf
Présentation IIRB 2024 Marine Cordonnier.pdf
 
Technology Features of Apollo HDD Machine, Its Technical Specification with C...
Technology Features of Apollo HDD Machine, Its Technical Specification with C...Technology Features of Apollo HDD Machine, Its Technical Specification with C...
Technology Features of Apollo HDD Machine, Its Technical Specification with C...
 
The relationship between iot and communication technology
The relationship between iot and communication technologyThe relationship between iot and communication technology
The relationship between iot and communication technology
 
Clutches and brkesSelect any 3 position random motion out of real world and d...
Clutches and brkesSelect any 3 position random motion out of real world and d...Clutches and brkesSelect any 3 position random motion out of real world and d...
Clutches and brkesSelect any 3 position random motion out of real world and d...
 
Transforming Process Safety Management: Challenges, Benefits, and Transition ...
Transforming Process Safety Management: Challenges, Benefits, and Transition ...Transforming Process Safety Management: Challenges, Benefits, and Transition ...
Transforming Process Safety Management: Challenges, Benefits, and Transition ...
 
EPE3163_Hydro power stations_Unit2_Lect2.pptx
EPE3163_Hydro power stations_Unit2_Lect2.pptxEPE3163_Hydro power stations_Unit2_Lect2.pptx
EPE3163_Hydro power stations_Unit2_Lect2.pptx
 
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
 
Best-NO1 Best Rohani Amil In Lahore Kala Ilam In Lahore Kala Jadu Amil In Lah...
Best-NO1 Best Rohani Amil In Lahore Kala Ilam In Lahore Kala Jadu Amil In Lah...Best-NO1 Best Rohani Amil In Lahore Kala Ilam In Lahore Kala Jadu Amil In Lah...
Best-NO1 Best Rohani Amil In Lahore Kala Ilam In Lahore Kala Jadu Amil In Lah...
 
Test of Significance of Large Samples for Mean = µ.pptx
Test of Significance of Large Samples for Mean = µ.pptxTest of Significance of Large Samples for Mean = µ.pptx
Test of Significance of Large Samples for Mean = µ.pptx
 
Lecture 2 .pptx
Lecture 2                            .pptxLecture 2                            .pptx
Lecture 2 .pptx
 
A Seminar on Electric Vehicle Software Simulation
A Seminar on Electric Vehicle Software SimulationA Seminar on Electric Vehicle Software Simulation
A Seminar on Electric Vehicle Software Simulation
 
ASME BPVC 2023 Section I para leer y entender
ASME BPVC 2023 Section I para leer y entenderASME BPVC 2023 Section I para leer y entender
ASME BPVC 2023 Section I para leer y entender
 
Basic Principle of Electrochemical Sensor
Basic Principle of  Electrochemical SensorBasic Principle of  Electrochemical Sensor
Basic Principle of Electrochemical Sensor
 
Design of Clutches and Brakes in Design of Machine Elements.pptx
Design of Clutches and Brakes in Design of Machine Elements.pptxDesign of Clutches and Brakes in Design of Machine Elements.pptx
Design of Clutches and Brakes in Design of Machine Elements.pptx
 
Phase noise transfer functions.pptx
Phase noise transfer      functions.pptxPhase noise transfer      functions.pptx
Phase noise transfer functions.pptx
 

Android service and gcm

  • 2. A service is a component which runs in the background without direct interaction with the user. As the service has no user interface, it is not bound to the lifecycle of an activity.
  • 3. Services are used for repetitive and potentially long running operations, i.e., Internet downloads, checking for new data
  • 6. A service needs to be declared in the AndroidManifest.xml file
  • 8. The implementing class must extend the Service class or one of its subclasses.
  • 10. An Android component (service, receiver, activity) can trigger the execution of a service via the startService(intent) method
  • 11. If the startService(intent) method is called and the service is not yet running, the service object is created and the onCreate() method of the service is called.
  • 12. Once the service is started, the onStartCommand(intent) method in the service is called. It passes in the Intent object from the startService (intent) call.
  • 13. If startService(intent) is called while the service is running, its onStartCommand() is also called. Therefore your service needs to be prepared that onStartCommand() can be called several times.
  • 14. You stop a service via the stopService() method. No matter how frequently you called the startService (intent) method, one call to the stopService() method stops the service
  • 15. A service can terminate itself by calling the stopSelf() method. This is typically done if the service finishes its work.
  • 17. By default, a service runs in the same process as the main thread of the application.
  • 18. Therefore,you need to use asynchronous processing in the service to perform resource intensive tasks in the background.
  • 19. IntentService is a base class for Services that handle asynchronous requests on demand. Clients send requests through startService(Intent) calls; the service is started as needed, and stops itself when it runs out of work.
  • 20. Declares a broadcast receiver as one of the application's components. Broadcast receivers enable applications to receive intents that are broadcast by the system or by other applications, even when other components of the application are not running. Receivers