SlideShare a Scribd company logo
1 of 14
Download to read offline
Android Services
Jim McKeeth
Lead Developer Evangelist
Embarcadero Technologies
About Jim McKeeth
• Lead World Wide Developer Evangelist
• Host of Podcast at Delphi.org
• Longtime developer
– Object Pascal, Java, C#, JavaScript, Objective-C, etc.
• Invented and patented swipe to unlock in 2000
– US Patent # 8352745 & 6766456, etc.
• Improvisational performer with ComedySportz Boise
Why Android Services?
• Provide background functionality
• Can run even when app is closed
• Can start on boot or other events
• Can be accessible by multiple apps
Android Services vs. Threads
Android Services
• Cannot access the UI
• Runs in main thread of
host app process
• Can contain multiple
threads
• Used for long running
processes
Threads
• Cannot access the UI
• Not accessible to other
apps
• Terminated with app
• Used to improve
responsiveness
Android Service Type Variations
• IntentService
– Handle asynchronous requests (onHandleIntent(Intent) event)
– Otherwise are syncronous (onStartCommand(Intent) event)
– Both are Bindable (onBind event)
• Local vs. Remote
– Local only accessible by host (exported = false in manifest)
– Remote cross app access (exported = true in manifest)
Android Service Wizard
• Local Service
– Synchronous local access
• Intent Local Service
– Asynchronous local access
• Remote Service
– Synchronous local & remote access
• Intent Remote Service
– Asynchronous local & remote access
Service Class Hierarchy
TDataModule
TAndroidBaseService
Adds OnBind,	OnUnBind,	
OnRebind,	OnTaskRemoved,	
OnConfigurationChanged,	
OnLowMemory,	OnTrimMemory,	
OnHandleMessage*,
JavaService &	JavaIntentService**
TAndroidService
Adds OnStartCommand
TAndroidIntentService
Adds OnHandleIntent
*OnHandleMessage only	
occurs	in	remote	services
**Only	JavaService xor
JavaIntentService will	have	a	
value,	otherwise	nil
Services in Delphi
• The Service is a separate project
• Referenced by, and included in host app
• Must build service before adding to host
• For best results put service in its own directory
How to use a Service
• We have two ways to use a Service:
1. Sending a request (startService(Intent))
It is used to execute an unattended work in background
return START_STICKY or START_REDELIVER_INTENT in OnStartCommand to
restart the service in case the app is closed
2. Bound to the service (bindService)
It is used to create a long-standing connection to interact with the service
3. Can use a combination of both
Service lifecycle
• Lifecycle and events
are different
depending on how
the service is started:
– Started
– Bound
More	information
http://developer.android.com/guide/components/services.html
Restrictions for Services
• Cannot Access UI
• Not use components from the FMX namespace
• Be aware of power consumption
– Using a lot of CPU
– Using network connection
• Respect users expectations and privacy
Service Workarounds
• Use RTL or low-level calls instead of FMX
components. If the service fails when started, use
a lower level call.
• Manually edit manifest to make remote services
published.
• Manually edit Java Templates for Intent and
Remote Services (see http://delphi.org/?p=2084)
DEMONSTRATIONS
Android Services
Summary
• Android services allow for execution even when
app is not running.
• Add a new Android Service project to your app.
• Build service before adding reference.
• More information:
– http://delphi.org/tag/android-services/
– http://embt.co/creating_android_services
– http://embt.co/android_service

More Related Content

Viewers also liked

Android Services Skill Sprint
Android Services Skill SprintAndroid Services Skill Sprint
Android Services Skill SprintJim McKeeth
 
Deep Dive into Futures and the Parallel Programming Library
Deep Dive into Futures and the Parallel Programming LibraryDeep Dive into Futures and the Parallel Programming Library
Deep Dive into Futures and the Parallel Programming LibraryJim McKeeth
 
Android App Development - 08 Services
Android App Development - 08 ServicesAndroid App Development - 08 Services
Android App Development - 08 ServicesDiego Grancini
 
Android M - Runtime Permissions | Getting ready for Marshmallow
Android M - Runtime Permissions | Getting ready for MarshmallowAndroid M - Runtime Permissions | Getting ready for Marshmallow
Android M - Runtime Permissions | Getting ready for MarshmallowUmair Vatao
 
Android interview questions
Android interview questionsAndroid interview questions
Android interview questionssatish reddy
 
Interview questions for an Android Developer
Interview questions for an Android DeveloperInterview questions for an Android Developer
Interview questions for an Android DeveloperInterview Mocha
 
Porting Flickr to YUI3 - F2E Summit
Porting Flickr to YUI3 - F2E SummitPorting Flickr to YUI3 - F2E Summit
Porting Flickr to YUI3 - F2E Summitrharmes
 
Financial analyst
Financial analystFinancial analyst
Financial analystChie Atsumi
 
"Продвигайте игровые приложения с Google", Санджар Исмаилов, Infudtry Manage...
"Продвигайте игровые приложения с Google", Санджар Исмаилов, Infudtry Manage..."Продвигайте игровые приложения с Google", Санджар Исмаилов, Infudtry Manage...
"Продвигайте игровые приложения с Google", Санджар Исмаилов, Infudtry Manage...Julia Lebedeva
 
De kleren van_sinterklaas
De kleren van_sinterklaasDe kleren van_sinterklaas
De kleren van_sinterklaasgroep12pius10
 
Economic Development Update - Garrett County, MD (09.24.2013)
Economic Development Update - Garrett County, MD (09.24.2013)Economic Development Update - Garrett County, MD (09.24.2013)
Economic Development Update - Garrett County, MD (09.24.2013)Kim Durst
 
Status Board 面白いよ!
Status Board 面白いよ!Status Board 面白いよ!
Status Board 面白いよ!Hishikawa Takuro
 

Viewers also liked (20)

Android Services Skill Sprint
Android Services Skill SprintAndroid Services Skill Sprint
Android Services Skill Sprint
 
Deep Dive into Futures and the Parallel Programming Library
Deep Dive into Futures and the Parallel Programming LibraryDeep Dive into Futures and the Parallel Programming Library
Deep Dive into Futures and the Parallel Programming Library
 
Android App Development - 08 Services
Android App Development - 08 ServicesAndroid App Development - 08 Services
Android App Development - 08 Services
 
Android M - Runtime Permissions | Getting ready for Marshmallow
Android M - Runtime Permissions | Getting ready for MarshmallowAndroid M - Runtime Permissions | Getting ready for Marshmallow
Android M - Runtime Permissions | Getting ready for Marshmallow
 
Android interview questions
Android interview questionsAndroid interview questions
Android interview questions
 
Interview questions for an Android Developer
Interview questions for an Android DeveloperInterview questions for an Android Developer
Interview questions for an Android Developer
 
Polímeros
PolímerosPolímeros
Polímeros
 
Porting Flickr to YUI3 - F2E Summit
Porting Flickr to YUI3 - F2E SummitPorting Flickr to YUI3 - F2E Summit
Porting Flickr to YUI3 - F2E Summit
 
Watchmen
WatchmenWatchmen
Watchmen
 
Financial analyst
Financial analystFinancial analyst
Financial analyst
 
Young1928
Young1928Young1928
Young1928
 
Web & Sostenibilità
Web & SostenibilitàWeb & Sostenibilità
Web & Sostenibilità
 
"Продвигайте игровые приложения с Google", Санджар Исмаилов, Infudtry Manage...
"Продвигайте игровые приложения с Google", Санджар Исмаилов, Infudtry Manage..."Продвигайте игровые приложения с Google", Санджар Исмаилов, Infudtry Manage...
"Продвигайте игровые приложения с Google", Санджар Исмаилов, Infudtry Manage...
 
4 introduccion a la ingenieria pag 37-40
4 introduccion a la ingenieria pag 37-404 introduccion a la ingenieria pag 37-40
4 introduccion a la ingenieria pag 37-40
 
De kleren van_sinterklaas
De kleren van_sinterklaasDe kleren van_sinterklaas
De kleren van_sinterklaas
 
AssoSCAI @brianzaamica
AssoSCAI @brianzaamicaAssoSCAI @brianzaamica
AssoSCAI @brianzaamica
 
T2_e2_rodriguez-noemi
T2_e2_rodriguez-noemiT2_e2_rodriguez-noemi
T2_e2_rodriguez-noemi
 
Economic Development Update - Garrett County, MD (09.24.2013)
Economic Development Update - Garrett County, MD (09.24.2013)Economic Development Update - Garrett County, MD (09.24.2013)
Economic Development Update - Garrett County, MD (09.24.2013)
 
Silicon Valley trip
Silicon Valley tripSilicon Valley trip
Silicon Valley trip
 
Status Board 面白いよ!
Status Board 面白いよ!Status Board 面白いよ!
Status Board 面白いよ!
 

Similar to Creating Android Services with Delphi and RAD Studio 10 Seattle

Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android DevelopmentOwain Lewis
 
Intro to Microservices Architecture
Intro to Microservices ArchitectureIntro to Microservices Architecture
Intro to Microservices ArchitecturePeter Nijem
 
What serverless means for enterprise apps
What serverless means for enterprise appsWhat serverless means for enterprise apps
What serverless means for enterprise appsSumit Sarkar
 
CNIT 128 7. Attacking Android Applications (Part 2)
CNIT 128 7. Attacking Android Applications (Part 2)CNIT 128 7. Attacking Android Applications (Part 2)
CNIT 128 7. Attacking Android Applications (Part 2)Sam Bowne
 
Creative Automation with Galen Framework
Creative Automation with Galen FrameworkCreative Automation with Galen Framework
Creative Automation with Galen Framework'Ashmeet Sehgal'
 
Fed London - January 2015
Fed London - January 2015Fed London - January 2015
Fed London - January 2015Phil Leggetter
 
Microservices: Yes or not?
Microservices: Yes or not?Microservices: Yes or not?
Microservices: Yes or not?Eduard Tomàs
 
Monolithic and Microservice architecture, Feature of Node JS 10, HTTP2
Monolithic and Microservice architecture, Feature of Node JS 10, HTTP2Monolithic and Microservice architecture, Feature of Node JS 10, HTTP2
Monolithic and Microservice architecture, Feature of Node JS 10, HTTP2Atharva Jawalkar
 
How to Build Front-End Web Apps that Scale - FutureJS
How to Build Front-End Web Apps that Scale - FutureJSHow to Build Front-End Web Apps that Scale - FutureJS
How to Build Front-End Web Apps that Scale - FutureJSPhil Leggetter
 
CNIT 128 7. Attacking Android Applications (Part 2)
CNIT 128 7. Attacking Android Applications (Part 2)CNIT 128 7. Attacking Android Applications (Part 2)
CNIT 128 7. Attacking Android Applications (Part 2)Sam Bowne
 
Microservice Architecture Patterns, by Richard Langlois P. Eng.
Microservice Architecture Patterns, by Richard Langlois P. Eng.Microservice Architecture Patterns, by Richard Langlois P. Eng.
Microservice Architecture Patterns, by Richard Langlois P. Eng.Richard Langlois P. Eng.
 
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)Sam Bowne
 
Twelve Factor App With Lagom
Twelve Factor App With LagomTwelve Factor App With Lagom
Twelve Factor App With LagomKnoldus Inc.
 
Yotpo microservices
Yotpo microservicesYotpo microservices
Yotpo microservicesRon Barabash
 
MICROSERVICES ARCHITECTURE unit -2.pptx
MICROSERVICES ARCHITECTURE unit -2.pptxMICROSERVICES ARCHITECTURE unit -2.pptx
MICROSERVICES ARCHITECTURE unit -2.pptxMohammedShahid562503
 

Similar to Creating Android Services with Delphi and RAD Studio 10 Seattle (20)

Explore Android Internals
Explore Android InternalsExplore Android Internals
Explore Android Internals
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Intro to Microservices Architecture
Intro to Microservices ArchitectureIntro to Microservices Architecture
Intro to Microservices Architecture
 
What serverless means for enterprise apps
What serverless means for enterprise appsWhat serverless means for enterprise apps
What serverless means for enterprise apps
 
CNIT 128 7. Attacking Android Applications (Part 2)
CNIT 128 7. Attacking Android Applications (Part 2)CNIT 128 7. Attacking Android Applications (Part 2)
CNIT 128 7. Attacking Android Applications (Part 2)
 
Creative Automation with Galen Framework
Creative Automation with Galen FrameworkCreative Automation with Galen Framework
Creative Automation with Galen Framework
 
Fed London - January 2015
Fed London - January 2015Fed London - January 2015
Fed London - January 2015
 
Microservices: Yes or not?
Microservices: Yes or not?Microservices: Yes or not?
Microservices: Yes or not?
 
Monolithic and Microservice architecture, Feature of Node JS 10, HTTP2
Monolithic and Microservice architecture, Feature of Node JS 10, HTTP2Monolithic and Microservice architecture, Feature of Node JS 10, HTTP2
Monolithic and Microservice architecture, Feature of Node JS 10, HTTP2
 
Basics 4
Basics   4Basics   4
Basics 4
 
How to Build Front-End Web Apps that Scale - FutureJS
How to Build Front-End Web Apps that Scale - FutureJSHow to Build Front-End Web Apps that Scale - FutureJS
How to Build Front-End Web Apps that Scale - FutureJS
 
CNIT 128 7. Attacking Android Applications (Part 2)
CNIT 128 7. Attacking Android Applications (Part 2)CNIT 128 7. Attacking Android Applications (Part 2)
CNIT 128 7. Attacking Android Applications (Part 2)
 
Microservice Architecture Patterns, by Richard Langlois P. Eng.
Microservice Architecture Patterns, by Richard Langlois P. Eng.Microservice Architecture Patterns, by Richard Langlois P. Eng.
Microservice Architecture Patterns, by Richard Langlois P. Eng.
 
4. system models
4. system models4. system models
4. system models
 
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)
 
Lakkakula Sunil Kumar
Lakkakula Sunil KumarLakkakula Sunil Kumar
Lakkakula Sunil Kumar
 
Twelve Factor App With Lagom
Twelve Factor App With LagomTwelve Factor App With Lagom
Twelve Factor App With Lagom
 
Microservices
MicroservicesMicroservices
Microservices
 
Yotpo microservices
Yotpo microservicesYotpo microservices
Yotpo microservices
 
MICROSERVICES ARCHITECTURE unit -2.pptx
MICROSERVICES ARCHITECTURE unit -2.pptxMICROSERVICES ARCHITECTURE unit -2.pptx
MICROSERVICES ARCHITECTURE unit -2.pptx
 

More from Jim McKeeth

Smart Contracts - The Blockchain Beyond Bitcoin
Smart Contracts - The Blockchain Beyond BitcoinSmart Contracts - The Blockchain Beyond Bitcoin
Smart Contracts - The Blockchain Beyond BitcoinJim McKeeth
 
Rapid Prototyping Mobile IoT Projects with Arduino and Open Hardware
Rapid Prototyping Mobile IoT Projects with Arduino and Open HardwareRapid Prototyping Mobile IoT Projects with Arduino and Open Hardware
Rapid Prototyping Mobile IoT Projects with Arduino and Open HardwareJim McKeeth
 
Day 3 of C++ Boot Camp - C++11 Language Deep Dive
Day 3 of C++ Boot Camp - C++11 Language Deep DiveDay 3 of C++ Boot Camp - C++11 Language Deep Dive
Day 3 of C++ Boot Camp - C++11 Language Deep DiveJim McKeeth
 
Day 5 of C++ Boot Camp - Stepping Up to Mobile
Day 5 of C++ Boot Camp - Stepping Up to MobileDay 5 of C++ Boot Camp - Stepping Up to Mobile
Day 5 of C++ Boot Camp - Stepping Up to MobileJim McKeeth
 
Building a Thought Controlled Drone
Building a Thought Controlled DroneBuilding a Thought Controlled Drone
Building a Thought Controlled DroneJim McKeeth
 
Embarcadero's Connected Development
Embarcadero's Connected DevelopmentEmbarcadero's Connected Development
Embarcadero's Connected DevelopmentJim McKeeth
 
The Internet of Things and You - A Developers Guide to IoT
The Internet of Things and You - A Developers Guide to IoTThe Internet of Things and You - A Developers Guide to IoT
The Internet of Things and You - A Developers Guide to IoTJim McKeeth
 
Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summ...
Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summ...Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summ...
Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summ...Jim McKeeth
 
Android voice skill sprint
Android voice skill sprintAndroid voice skill sprint
Android voice skill sprintJim McKeeth
 
Exploring the Brain Computer Interface
Exploring the Brain Computer InterfaceExploring the Brain Computer Interface
Exploring the Brain Computer InterfaceJim McKeeth
 
Introduction to Android Development with Java
Introduction to Android Development with JavaIntroduction to Android Development with Java
Introduction to Android Development with JavaJim McKeeth
 
Hacking iBooks and ePub3 with JavaScript!
Hacking iBooks and ePub3 with JavaScript!Hacking iBooks and ePub3 with JavaScript!
Hacking iBooks and ePub3 with JavaScript!Jim McKeeth
 
Inventing merit badge
Inventing merit badgeInventing merit badge
Inventing merit badgeJim McKeeth
 

More from Jim McKeeth (13)

Smart Contracts - The Blockchain Beyond Bitcoin
Smart Contracts - The Blockchain Beyond BitcoinSmart Contracts - The Blockchain Beyond Bitcoin
Smart Contracts - The Blockchain Beyond Bitcoin
 
Rapid Prototyping Mobile IoT Projects with Arduino and Open Hardware
Rapid Prototyping Mobile IoT Projects with Arduino and Open HardwareRapid Prototyping Mobile IoT Projects with Arduino and Open Hardware
Rapid Prototyping Mobile IoT Projects with Arduino and Open Hardware
 
Day 3 of C++ Boot Camp - C++11 Language Deep Dive
Day 3 of C++ Boot Camp - C++11 Language Deep DiveDay 3 of C++ Boot Camp - C++11 Language Deep Dive
Day 3 of C++ Boot Camp - C++11 Language Deep Dive
 
Day 5 of C++ Boot Camp - Stepping Up to Mobile
Day 5 of C++ Boot Camp - Stepping Up to MobileDay 5 of C++ Boot Camp - Stepping Up to Mobile
Day 5 of C++ Boot Camp - Stepping Up to Mobile
 
Building a Thought Controlled Drone
Building a Thought Controlled DroneBuilding a Thought Controlled Drone
Building a Thought Controlled Drone
 
Embarcadero's Connected Development
Embarcadero's Connected DevelopmentEmbarcadero's Connected Development
Embarcadero's Connected Development
 
The Internet of Things and You - A Developers Guide to IoT
The Internet of Things and You - A Developers Guide to IoTThe Internet of Things and You - A Developers Guide to IoT
The Internet of Things and You - A Developers Guide to IoT
 
Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summ...
Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summ...Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summ...
Accessing REST & Backend as a Service (BaaS) - Developer Direct - Mobile Summ...
 
Android voice skill sprint
Android voice skill sprintAndroid voice skill sprint
Android voice skill sprint
 
Exploring the Brain Computer Interface
Exploring the Brain Computer InterfaceExploring the Brain Computer Interface
Exploring the Brain Computer Interface
 
Introduction to Android Development with Java
Introduction to Android Development with JavaIntroduction to Android Development with Java
Introduction to Android Development with Java
 
Hacking iBooks and ePub3 with JavaScript!
Hacking iBooks and ePub3 with JavaScript!Hacking iBooks and ePub3 with JavaScript!
Hacking iBooks and ePub3 with JavaScript!
 
Inventing merit badge
Inventing merit badgeInventing merit badge
Inventing merit badge
 

Recently uploaded

Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 

Recently uploaded (20)

Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 

Creating Android Services with Delphi and RAD Studio 10 Seattle

  • 1. Android Services Jim McKeeth Lead Developer Evangelist Embarcadero Technologies
  • 2. About Jim McKeeth • Lead World Wide Developer Evangelist • Host of Podcast at Delphi.org • Longtime developer – Object Pascal, Java, C#, JavaScript, Objective-C, etc. • Invented and patented swipe to unlock in 2000 – US Patent # 8352745 & 6766456, etc. • Improvisational performer with ComedySportz Boise
  • 3. Why Android Services? • Provide background functionality • Can run even when app is closed • Can start on boot or other events • Can be accessible by multiple apps
  • 4. Android Services vs. Threads Android Services • Cannot access the UI • Runs in main thread of host app process • Can contain multiple threads • Used for long running processes Threads • Cannot access the UI • Not accessible to other apps • Terminated with app • Used to improve responsiveness
  • 5. Android Service Type Variations • IntentService – Handle asynchronous requests (onHandleIntent(Intent) event) – Otherwise are syncronous (onStartCommand(Intent) event) – Both are Bindable (onBind event) • Local vs. Remote – Local only accessible by host (exported = false in manifest) – Remote cross app access (exported = true in manifest)
  • 6. Android Service Wizard • Local Service – Synchronous local access • Intent Local Service – Asynchronous local access • Remote Service – Synchronous local & remote access • Intent Remote Service – Asynchronous local & remote access
  • 7. Service Class Hierarchy TDataModule TAndroidBaseService Adds OnBind, OnUnBind, OnRebind, OnTaskRemoved, OnConfigurationChanged, OnLowMemory, OnTrimMemory, OnHandleMessage*, JavaService & JavaIntentService** TAndroidService Adds OnStartCommand TAndroidIntentService Adds OnHandleIntent *OnHandleMessage only occurs in remote services **Only JavaService xor JavaIntentService will have a value, otherwise nil
  • 8. Services in Delphi • The Service is a separate project • Referenced by, and included in host app • Must build service before adding to host • For best results put service in its own directory
  • 9. How to use a Service • We have two ways to use a Service: 1. Sending a request (startService(Intent)) It is used to execute an unattended work in background return START_STICKY or START_REDELIVER_INTENT in OnStartCommand to restart the service in case the app is closed 2. Bound to the service (bindService) It is used to create a long-standing connection to interact with the service 3. Can use a combination of both
  • 10. Service lifecycle • Lifecycle and events are different depending on how the service is started: – Started – Bound More information http://developer.android.com/guide/components/services.html
  • 11. Restrictions for Services • Cannot Access UI • Not use components from the FMX namespace • Be aware of power consumption – Using a lot of CPU – Using network connection • Respect users expectations and privacy
  • 12. Service Workarounds • Use RTL or low-level calls instead of FMX components. If the service fails when started, use a lower level call. • Manually edit manifest to make remote services published. • Manually edit Java Templates for Intent and Remote Services (see http://delphi.org/?p=2084)
  • 14. Summary • Android services allow for execution even when app is not running. • Add a new Android Service project to your app. • Build service before adding reference. • More information: – http://delphi.org/tag/android-services/ – http://embt.co/creating_android_services – http://embt.co/android_service