SlideShare uma empresa Scribd logo
1 de 23
Baixar para ler offline
DEVELOPING ANDROID CLIENT
APPS VIA SYNCADAPTER
Anatoliy Kaverin
Lohika @ 2013
SESSION AGENDA
 Why?
 SyncAdapter!? LOLWUT?
 The big picture
 Puzzles
 Does anybody use it?
 Code samples, documentation
 Q&A
2
IMAGINE…
SIMPLE CLIENT-SERVER APP
3
SYNC CACHE: ISSUES TO CONSIDER
Are we done?
 Global Sync setting
 Bandwidth starvation
 YES, queued
 YES, even duplicates
 YES, even if app is off
 YES, built in support
Hand-made  SyncAdapter framework
 Network availability
 Pending queue
 Refresh on network
 Periodic update
 YES, manual override
 YES! YES! YES!
4
SYNCADAPTER!? LOLWUT?
 Well, you probably use it everyday…
5
THE BIG PICTURE – BASIC FLOW
6
THE BIG PICTURE – PUZZLES
7
PREREQUISITES TO CONSIDER
 Network layer separation
 Plain implementation
 Sync status field for synced entities
 Usually NOOP, Created, Updated & Deleted
 Consider the field in UI flows
 Consider partial sync
 For better performance to sync only local delta
8
PUZZLES – ACCOUNT (1)
 Key Features
 Manage credentials;
 Safe system store;
 Multitenant support
 Sync related
 Token caching and invalidation
 Alternative flow to login or sign in
 Store extra data with account
9
PUZZLES – ACCOUNT (2)
 Checklist:
 Implement Authenticator
 Implement Authentication Service
 Define configuration in XML
10
PUZZLES – ACCOUNT (3)
 Checklist:
 Register Authentication Service in AndroidManifest
 Add permissions
 APIs to use:
 android.accounts.AccountManager to work with accounts
 android.accounts.Account to store credentials
11
PUZZLES – CONTENT PROVIDER (1)
 Key features
 Heart of DAO
 Resource effective
 Cursor, resource-effective scalability
 Power of Joins
 Built-in ListView refresh via ContentObserver &
Cursor
 Sync related
 Acts as mediator for sync and UI layers
 Supports automatic delta upload sync
 NOTE: Can be fake one, but you’ll lose a lot of magic
 12
PUZZLES – CONTENT PROVIDER (2)
 Minimal implementation based on
https://github.com/novoda/SQLiteProvider
 Supports all CRUD
 Supports DB versioning
 And even more…
13
PUZZLES – SYNCADAPTER (1)
 Key features
 Plugin to Android SyncManager
 SyncManager manages queue of execution
 Adapter is executed in background thread & when
network is available
 Sync related
 Scheduling & automated mode
 Respects system settings
 Can be overridden by manual request
 Partial sync supported
 Upload only local delta
 Any other criteria (Bundle) 14
PUZZLES – SYNCADAPTER (2)
 Checklist
 Implement SyncAdapter class
 Implement Sync Service
 Define configuration xml
15
PUZZLES – SYNCADAPTER (3)
 Checklist
 Register Sync Service in AndroidManifest
 Add permissions
 APIs to use
 android.content.ContentResolver to reach SyncManager
programmatically
16
PUZZLES – SYNCADAPTER (4)
 How to trigger sync?
 Upload delta
 ContentResolver.notifyChange
 Be aware of cyclic calls if used in ContentProvider
 Scheduling
 ContentResolver.addPeriodicSync
 Automated
 ContentResolver.setSyncAutomatically
 Manual
 ContentResolver.requestSync
 Manual forced
 ContentResolver.requestSync
 Pass SYNC_EXTRAS_MANUAL in bundle
17
THE BIG PICTURE – OPTIONAL PUZZLES
18
PROS & CONS
 Pros
 Simplify server interaction
 A lot of work handled by framework
 Resource effective – the Android way
 Cons
 A lot of puzzles, hard to start…
 Lack of documentation
 Error handling
 Bugs 
19
DOESANYBODYUSEIT?
20
DOCUMENTATION
 Official docs
 Great tutorial added in August ’13
http://developer.android.com/training/sync-
adapters/index.html + code sample
 Stackoverflow, use tags below
 [android-syncadapter]
 [sync] + [android]
21
BONUS: CODE SAMPLES
 Repo on GitHub
https://github.com/springbyexample/spring-by-
example
 Toy client-server app (both parties supplied )
 Shows all puzzles implemented:
 Accounts – fake one, there is no authentication
 Content Provider based on novoda library
 SyncAdapter logics
 All wrapping XML configuration
 Built via Maven
 Follow README and be happy 
 Got questions?
 a.kaverin@gmail.com 22
Q & A
Thanks for your attention!23

Mais conteúdo relacionado

Mais procurados

Nyc mule soft_meetup_13_march_2021
Nyc mule soft_meetup_13_march_2021Nyc mule soft_meetup_13_march_2021
Nyc mule soft_meetup_13_march_2021NeerajKumar1965
 
First Look at Azure Logic Apps (BAUG)
First Look at Azure Logic Apps (BAUG)First Look at Azure Logic Apps (BAUG)
First Look at Azure Logic Apps (BAUG)Daniel Toomey
 
Connector API Apps
Connector API AppsConnector API Apps
Connector API AppsBizTalk360
 
日本開發者大會短講分享
日本開發者大會短講分享日本開發者大會短講分享
日本開發者大會短講分享LINE Corporation
 
WebSphere Connect and API Discovery
WebSphere Connect and API DiscoveryWebSphere Connect and API Discovery
WebSphere Connect and API Discovery Arthur De Magalhaes
 
MuleSoft Surat Live Demonstration Virtual Meetup#4 - Automate Anypoint VPC, V...
MuleSoft Surat Live Demonstration Virtual Meetup#4 - Automate Anypoint VPC, V...MuleSoft Surat Live Demonstration Virtual Meetup#4 - Automate Anypoint VPC, V...
MuleSoft Surat Live Demonstration Virtual Meetup#4 - Automate Anypoint VPC, V...Jitendra Bafna
 
Cloud Native Java with Spring Cloud Services
Cloud Native Java with Spring Cloud ServicesCloud Native Java with Spring Cloud Services
Cloud Native Java with Spring Cloud ServicesVMware Tanzu
 
Building a Lightning App with Angular Material Design
Building a Lightning App with Angular Material DesignBuilding a Lightning App with Angular Material Design
Building a Lightning App with Angular Material DesignSalesforce Developers
 
Development Process Optimization Using Docker. Based on a True Story
Development Process Optimization Using Docker. Based on a True StoryDevelopment Process Optimization Using Docker. Based on a True Story
Development Process Optimization Using Docker. Based on a True StoryGlobalLogic Ukraine
 
Securing SharePoint Apps with OAuth
Securing SharePoint Apps with OAuthSecuring SharePoint Apps with OAuth
Securing SharePoint Apps with OAuthKashif Imran
 
Inside Logic Apps
Inside Logic AppsInside Logic Apps
Inside Logic AppsBizTalk360
 
[WSO2Con Asia 2018] Managing API Integrations with WSO2 API Manager
[WSO2Con Asia 2018] Managing API Integrations with WSO2 API Manager[WSO2Con Asia 2018] Managing API Integrations with WSO2 API Manager
[WSO2Con Asia 2018] Managing API Integrations with WSO2 API ManagerWSO2
 
Deploying applications to Cloud with Google App Engine
Deploying applications to Cloud with Google App EngineDeploying applications to Cloud with Google App Engine
Deploying applications to Cloud with Google App EngineAlexander Zamkovyi
 
Unleash the power of Serverless Computing
Unleash the power of Serverless ComputingUnleash the power of Serverless Computing
Unleash the power of Serverless ComputingGaurav Madaan
 
Build a REST API for your Mobile Apps using Node.js
Build a REST API for your Mobile Apps using Node.jsBuild a REST API for your Mobile Apps using Node.js
Build a REST API for your Mobile Apps using Node.jsStormpath
 
mdevcon - A Primer to SyncAdapters
mdevcon  - A Primer to SyncAdaptersmdevcon  - A Primer to SyncAdapters
mdevcon - A Primer to SyncAdaptersKiana Tennyson
 

Mais procurados (20)

Nyc mule soft_meetup_13_march_2021
Nyc mule soft_meetup_13_march_2021Nyc mule soft_meetup_13_march_2021
Nyc mule soft_meetup_13_march_2021
 
First Look at Azure Logic Apps (BAUG)
First Look at Azure Logic Apps (BAUG)First Look at Azure Logic Apps (BAUG)
First Look at Azure Logic Apps (BAUG)
 
Vaadin codemotion 2014
Vaadin codemotion 2014Vaadin codemotion 2014
Vaadin codemotion 2014
 
Connector API Apps
Connector API AppsConnector API Apps
Connector API Apps
 
日本開發者大會短講分享
日本開發者大會短講分享日本開發者大會短講分享
日本開發者大會短講分享
 
WebSphere Connect and API Discovery
WebSphere Connect and API DiscoveryWebSphere Connect and API Discovery
WebSphere Connect and API Discovery
 
MuleSoft Surat Live Demonstration Virtual Meetup#4 - Automate Anypoint VPC, V...
MuleSoft Surat Live Demonstration Virtual Meetup#4 - Automate Anypoint VPC, V...MuleSoft Surat Live Demonstration Virtual Meetup#4 - Automate Anypoint VPC, V...
MuleSoft Surat Live Demonstration Virtual Meetup#4 - Automate Anypoint VPC, V...
 
Cloud Native Java with Spring Cloud Services
Cloud Native Java with Spring Cloud ServicesCloud Native Java with Spring Cloud Services
Cloud Native Java with Spring Cloud Services
 
Meteor Introduction - Ashish
Meteor Introduction - AshishMeteor Introduction - Ashish
Meteor Introduction - Ashish
 
Building a Lightning App with Angular Material Design
Building a Lightning App with Angular Material DesignBuilding a Lightning App with Angular Material Design
Building a Lightning App with Angular Material Design
 
Development Process Optimization Using Docker. Based on a True Story
Development Process Optimization Using Docker. Based on a True StoryDevelopment Process Optimization Using Docker. Based on a True Story
Development Process Optimization Using Docker. Based on a True Story
 
Securing SharePoint Apps with OAuth
Securing SharePoint Apps with OAuthSecuring SharePoint Apps with OAuth
Securing SharePoint Apps with OAuth
 
Inside Logic Apps
Inside Logic AppsInside Logic Apps
Inside Logic Apps
 
[WSO2Con Asia 2018] Managing API Integrations with WSO2 API Manager
[WSO2Con Asia 2018] Managing API Integrations with WSO2 API Manager[WSO2Con Asia 2018] Managing API Integrations with WSO2 API Manager
[WSO2Con Asia 2018] Managing API Integrations with WSO2 API Manager
 
Android CI and Appium
Android CI and AppiumAndroid CI and Appium
Android CI and Appium
 
Deploying applications to Cloud with Google App Engine
Deploying applications to Cloud with Google App EngineDeploying applications to Cloud with Google App Engine
Deploying applications to Cloud with Google App Engine
 
Unleash the power of Serverless Computing
Unleash the power of Serverless ComputingUnleash the power of Serverless Computing
Unleash the power of Serverless Computing
 
Build a REST API for your Mobile Apps using Node.js
Build a REST API for your Mobile Apps using Node.jsBuild a REST API for your Mobile Apps using Node.js
Build a REST API for your Mobile Apps using Node.js
 
Google app engine by example
Google app engine by exampleGoogle app engine by example
Google app engine by example
 
mdevcon - A Primer to SyncAdapters
mdevcon  - A Primer to SyncAdaptersmdevcon  - A Primer to SyncAdapters
mdevcon - A Primer to SyncAdapters
 

Destaque

Sync on Android
Sync on AndroidSync on Android
Sync on Androidchalup
 
Android ui adapter
Android ui adapterAndroid ui adapter
Android ui adapterKrazy Koder
 
SyncAdapter, Sincronização de dados no Android
SyncAdapter, Sincronização de dados no AndroidSyncAdapter, Sincronização de dados no Android
SyncAdapter, Sincronização de dados no AndroidEduardo Costa
 
Inside the Android AccountManager
Inside the Android AccountManagerInside the Android AccountManager
Inside the Android AccountManagerSamael Wang
 
Adapter and cache technique
Adapter and cache techniqueAdapter and cache technique
Adapter and cache techniqueHoang Vy Nguyen
 
Lecture Slides for List Views [Android ]
Lecture Slides for List Views [Android ]Lecture Slides for List Views [Android ]
Lecture Slides for List Views [Android ]Nehil Jain
 
Android Training (AdapterView & Adapter)
Android Training (AdapterView & Adapter)Android Training (AdapterView & Adapter)
Android Training (AdapterView & Adapter)Khaled Anaqwa
 
Command and Adapter Pattern
Command and Adapter PatternCommand and Adapter Pattern
Command and Adapter PatternJonathan Simon
 
Android development - ListView & Adapter
Android development - ListView & AdapterAndroid development - ListView & Adapter
Android development - ListView & AdapterLope Emano
 
Adapter & ListView & ExpandalbeListView
Adapter & ListView & ExpandalbeListViewAdapter & ListView & ExpandalbeListView
Adapter & ListView & ExpandalbeListViewYuki Anzai
 
Design Patterns - 04 Adapter and Facade Pattern
Design Patterns - 04 Adapter and Facade PatternDesign Patterns - 04 Adapter and Facade Pattern
Design Patterns - 04 Adapter and Facade Patterneprafulla
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Patternguy_davis
 

Destaque (13)

Sync on Android
Sync on AndroidSync on Android
Sync on Android
 
Android ui adapter
Android ui adapterAndroid ui adapter
Android ui adapter
 
Android adapters
Android adaptersAndroid adapters
Android adapters
 
SyncAdapter, Sincronização de dados no Android
SyncAdapter, Sincronização de dados no AndroidSyncAdapter, Sincronização de dados no Android
SyncAdapter, Sincronização de dados no Android
 
Inside the Android AccountManager
Inside the Android AccountManagerInside the Android AccountManager
Inside the Android AccountManager
 
Adapter and cache technique
Adapter and cache techniqueAdapter and cache technique
Adapter and cache technique
 
Lecture Slides for List Views [Android ]
Lecture Slides for List Views [Android ]Lecture Slides for List Views [Android ]
Lecture Slides for List Views [Android ]
 
Android Training (AdapterView & Adapter)
Android Training (AdapterView & Adapter)Android Training (AdapterView & Adapter)
Android Training (AdapterView & Adapter)
 
Command and Adapter Pattern
Command and Adapter PatternCommand and Adapter Pattern
Command and Adapter Pattern
 
Android development - ListView & Adapter
Android development - ListView & AdapterAndroid development - ListView & Adapter
Android development - ListView & Adapter
 
Adapter & ListView & ExpandalbeListView
Adapter & ListView & ExpandalbeListViewAdapter & ListView & ExpandalbeListView
Adapter & ListView & ExpandalbeListView
 
Design Patterns - 04 Adapter and Facade Pattern
Design Patterns - 04 Adapter and Facade PatternDesign Patterns - 04 Adapter and Facade Pattern
Design Patterns - 04 Adapter and Facade Pattern
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 

Semelhante a Android sync adapter

Campus portal for wireless devices srs
Campus portal for wireless devices srsCampus portal for wireless devices srs
Campus portal for wireless devices srsAnand Goyal
 
Spring Boot & Spring Cloud Apps on Pivotal Application Service - Daniel Lavoie
Spring Boot & Spring Cloud Apps on Pivotal Application Service - Daniel LavoieSpring Boot & Spring Cloud Apps on Pivotal Application Service - Daniel Lavoie
Spring Boot & Spring Cloud Apps on Pivotal Application Service - Daniel LavoieVMware Tanzu
 
Device APIs at TakeOff Conference
Device APIs at TakeOff ConferenceDevice APIs at TakeOff Conference
Device APIs at TakeOff Conferencedianacheng
 
Cloud-native Java EE-volution
Cloud-native Java EE-volutionCloud-native Java EE-volution
Cloud-native Java EE-volutionQAware GmbH
 
SpringOne Tour Denver - Spring Boot & Spring Cloud on Pivotal Application Ser...
SpringOne Tour Denver - Spring Boot & Spring Cloud on Pivotal Application Ser...SpringOne Tour Denver - Spring Boot & Spring Cloud on Pivotal Application Ser...
SpringOne Tour Denver - Spring Boot & Spring Cloud on Pivotal Application Ser...VMware Tanzu
 
GDG Devfest 2016 session on Android N
GDG Devfest 2016 session on Android NGDG Devfest 2016 session on Android N
GDG Devfest 2016 session on Android NImam Raza
 
Spring and Pivotal Application Service - SpringOne Tour - Boston
Spring and Pivotal Application Service - SpringOne Tour - BostonSpring and Pivotal Application Service - SpringOne Tour - Boston
Spring and Pivotal Application Service - SpringOne Tour - BostonVMware Tanzu
 
OpenShift Taiwan Vol.1 Technology Overview
OpenShift Taiwan Vol.1 Technology OverviewOpenShift Taiwan Vol.1 Technology Overview
OpenShift Taiwan Vol.1 Technology OverviewJason Peng
 
ANDROID presentation prabal
ANDROID presentation prabalANDROID presentation prabal
ANDROID presentation prabalPrabal Tyagi
 
What's New in Docker - February 2017
What's New in Docker - February 2017What's New in Docker - February 2017
What's New in Docker - February 2017Patrick Chanezon
 
Raising ux bar with offline first design
Raising ux bar with offline first designRaising ux bar with offline first design
Raising ux bar with offline first designKyrylo Reznykov
 
Cross Platform Mobile Technologies
Cross Platform Mobile TechnologiesCross Platform Mobile Technologies
Cross Platform Mobile TechnologiesTalentica Software
 
Rhomobile 5.5 Release Notes
Rhomobile 5.5 Release NotesRhomobile 5.5 Release Notes
Rhomobile 5.5 Release NotesKonstantin Rybas
 
Convertigo Mobility Platform | Mobile Application Development for Enterprises...
Convertigo Mobility Platform | Mobile Application Development for Enterprises...Convertigo Mobility Platform | Mobile Application Development for Enterprises...
Convertigo Mobility Platform | Mobile Application Development for Enterprises...Convertigo | MADP & MBaaS
 
Let's talk about the future: state-of-the-art mobile web & hybrid apps
Let's talk about the future: state-of-the-art mobile web & hybrid appsLet's talk about the future: state-of-the-art mobile web & hybrid apps
Let's talk about the future: state-of-the-art mobile web & hybrid appsRakuten Group, Inc.
 
Campus portal for wireless devices
Campus portal for wireless devicesCampus portal for wireless devices
Campus portal for wireless devicesShiladitya Mandal
 
"Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?""Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?"Volker Linz
 
"Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai...
"Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai..."Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai...
"Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai...Fwdays
 

Semelhante a Android sync adapter (20)

Campus portal for wireless devices srs
Campus portal for wireless devices srsCampus portal for wireless devices srs
Campus portal for wireless devices srs
 
Spring Boot & Spring Cloud Apps on Pivotal Application Service - Daniel Lavoie
Spring Boot & Spring Cloud Apps on Pivotal Application Service - Daniel LavoieSpring Boot & Spring Cloud Apps on Pivotal Application Service - Daniel Lavoie
Spring Boot & Spring Cloud Apps on Pivotal Application Service - Daniel Lavoie
 
Android Anatomy
Android  AnatomyAndroid  Anatomy
Android Anatomy
 
Device APIs at TakeOff Conference
Device APIs at TakeOff ConferenceDevice APIs at TakeOff Conference
Device APIs at TakeOff Conference
 
Cloud-native Java EE-volution
Cloud-native Java EE-volutionCloud-native Java EE-volution
Cloud-native Java EE-volution
 
SpringOne Tour Denver - Spring Boot & Spring Cloud on Pivotal Application Ser...
SpringOne Tour Denver - Spring Boot & Spring Cloud on Pivotal Application Ser...SpringOne Tour Denver - Spring Boot & Spring Cloud on Pivotal Application Ser...
SpringOne Tour Denver - Spring Boot & Spring Cloud on Pivotal Application Ser...
 
GDG Devfest 2016 session on Android N
GDG Devfest 2016 session on Android NGDG Devfest 2016 session on Android N
GDG Devfest 2016 session on Android N
 
Spring and Pivotal Application Service - SpringOne Tour - Boston
Spring and Pivotal Application Service - SpringOne Tour - BostonSpring and Pivotal Application Service - SpringOne Tour - Boston
Spring and Pivotal Application Service - SpringOne Tour - Boston
 
OpenShift Taiwan Vol.1 Technology Overview
OpenShift Taiwan Vol.1 Technology OverviewOpenShift Taiwan Vol.1 Technology Overview
OpenShift Taiwan Vol.1 Technology Overview
 
ANDROID presentation prabal
ANDROID presentation prabalANDROID presentation prabal
ANDROID presentation prabal
 
What's New in Docker - February 2017
What's New in Docker - February 2017What's New in Docker - February 2017
What's New in Docker - February 2017
 
Raising ux bar with offline first design
Raising ux bar with offline first designRaising ux bar with offline first design
Raising ux bar with offline first design
 
Android session-1-sajib
Android session-1-sajibAndroid session-1-sajib
Android session-1-sajib
 
Cross Platform Mobile Technologies
Cross Platform Mobile TechnologiesCross Platform Mobile Technologies
Cross Platform Mobile Technologies
 
Rhomobile 5.5 Release Notes
Rhomobile 5.5 Release NotesRhomobile 5.5 Release Notes
Rhomobile 5.5 Release Notes
 
Convertigo Mobility Platform | Mobile Application Development for Enterprises...
Convertigo Mobility Platform | Mobile Application Development for Enterprises...Convertigo Mobility Platform | Mobile Application Development for Enterprises...
Convertigo Mobility Platform | Mobile Application Development for Enterprises...
 
Let's talk about the future: state-of-the-art mobile web & hybrid apps
Let's talk about the future: state-of-the-art mobile web & hybrid appsLet's talk about the future: state-of-the-art mobile web & hybrid apps
Let's talk about the future: state-of-the-art mobile web & hybrid apps
 
Campus portal for wireless devices
Campus portal for wireless devicesCampus portal for wireless devices
Campus portal for wireless devices
 
"Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?""Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?"
 
"Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai...
"Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai..."Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai...
"Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai...
 

Mais de Alex Tumanoff

Sql server 2019 New Features by Yevhen Nedaskivskyi
Sql server 2019 New Features by Yevhen NedaskivskyiSql server 2019 New Features by Yevhen Nedaskivskyi
Sql server 2019 New Features by Yevhen NedaskivskyiAlex Tumanoff
 
Odessa .net-user-group-sql-server-2019-hidden-gems by Denis Reznik
Odessa .net-user-group-sql-server-2019-hidden-gems by Denis ReznikOdessa .net-user-group-sql-server-2019-hidden-gems by Denis Reznik
Odessa .net-user-group-sql-server-2019-hidden-gems by Denis ReznikAlex Tumanoff
 
Azure data bricks by Eugene Polonichko
Azure data bricks by Eugene PolonichkoAzure data bricks by Eugene Polonichko
Azure data bricks by Eugene PolonichkoAlex Tumanoff
 
Sdlc by Anatoliy Anthony Cox
Sdlc by  Anatoliy Anthony CoxSdlc by  Anatoliy Anthony Cox
Sdlc by Anatoliy Anthony CoxAlex Tumanoff
 
Kostenko ux november-2014_1
Kostenko ux november-2014_1Kostenko ux november-2014_1
Kostenko ux november-2014_1Alex Tumanoff
 
Java 8 in action.jinq.v.1.3
Java 8 in action.jinq.v.1.3Java 8 in action.jinq.v.1.3
Java 8 in action.jinq.v.1.3Alex Tumanoff
 
"Drools: декларативная бизнес-логика в Java-приложениях" by Дмитрий Контрерас...
"Drools: декларативная бизнес-логика в Java-приложениях" by Дмитрий Контрерас..."Drools: декларативная бизнес-логика в Java-приложениях" by Дмитрий Контрерас...
"Drools: декларативная бизнес-логика в Java-приложениях" by Дмитрий Контрерас...Alex Tumanoff
 
Sql saturday azure storage by Anton Vidishchev
Sql saturday azure storage by Anton VidishchevSql saturday azure storage by Anton Vidishchev
Sql saturday azure storage by Anton VidishchevAlex Tumanoff
 
Navigation map factory by Alexey Klimenko
Navigation map factory by Alexey KlimenkoNavigation map factory by Alexey Klimenko
Navigation map factory by Alexey KlimenkoAlex Tumanoff
 
Serialization and performance by Sergey Morenets
Serialization and performance by Sergey MorenetsSerialization and performance by Sergey Morenets
Serialization and performance by Sergey MorenetsAlex Tumanoff
 
Игры для мобильных платформ by Алексей Рыбаков
Игры для мобильных платформ by Алексей РыбаковИгры для мобильных платформ by Алексей Рыбаков
Игры для мобильных платформ by Алексей РыбаковAlex Tumanoff
 
Async clinic by by Sergey Teplyakov
Async clinic by by Sergey TeplyakovAsync clinic by by Sergey Teplyakov
Async clinic by by Sergey TeplyakovAlex Tumanoff
 
Deep Dive C# by Sergey Teplyakov
Deep Dive  C# by Sergey TeplyakovDeep Dive  C# by Sergey Teplyakov
Deep Dive C# by Sergey TeplyakovAlex Tumanoff
 
Bdd by Dmitri Aizenberg
Bdd by Dmitri AizenbergBdd by Dmitri Aizenberg
Bdd by Dmitri AizenbergAlex Tumanoff
 
Неформальные размышления о сертификации в IT
Неформальные размышления о сертификации в ITНеформальные размышления о сертификации в IT
Неформальные размышления о сертификации в ITAlex Tumanoff
 
Разработка расширений Firefox
Разработка расширений FirefoxРазработка расширений Firefox
Разработка расширений FirefoxAlex Tumanoff
 
"AnnotatedSQL - провайдер с плюшками за 5 минут" - Геннадий Дубина, Senior So...
"AnnotatedSQL - провайдер с плюшками за 5 минут" - Геннадий Дубина, Senior So..."AnnotatedSQL - провайдер с плюшками за 5 минут" - Геннадий Дубина, Senior So...
"AnnotatedSQL - провайдер с плюшками за 5 минут" - Геннадий Дубина, Senior So...Alex Tumanoff
 
Patterns of parallel programming
Patterns of parallel programmingPatterns of parallel programming
Patterns of parallel programmingAlex Tumanoff
 
Lambda выражения и Java 8
Lambda выражения и Java 8Lambda выражения и Java 8
Lambda выражения и Java 8Alex Tumanoff
 

Mais de Alex Tumanoff (20)

Sql server 2019 New Features by Yevhen Nedaskivskyi
Sql server 2019 New Features by Yevhen NedaskivskyiSql server 2019 New Features by Yevhen Nedaskivskyi
Sql server 2019 New Features by Yevhen Nedaskivskyi
 
Odessa .net-user-group-sql-server-2019-hidden-gems by Denis Reznik
Odessa .net-user-group-sql-server-2019-hidden-gems by Denis ReznikOdessa .net-user-group-sql-server-2019-hidden-gems by Denis Reznik
Odessa .net-user-group-sql-server-2019-hidden-gems by Denis Reznik
 
Azure data bricks by Eugene Polonichko
Azure data bricks by Eugene PolonichkoAzure data bricks by Eugene Polonichko
Azure data bricks by Eugene Polonichko
 
Sdlc by Anatoliy Anthony Cox
Sdlc by  Anatoliy Anthony CoxSdlc by  Anatoliy Anthony Cox
Sdlc by Anatoliy Anthony Cox
 
Kostenko ux november-2014_1
Kostenko ux november-2014_1Kostenko ux november-2014_1
Kostenko ux november-2014_1
 
Java 8 in action.jinq.v.1.3
Java 8 in action.jinq.v.1.3Java 8 in action.jinq.v.1.3
Java 8 in action.jinq.v.1.3
 
"Drools: декларативная бизнес-логика в Java-приложениях" by Дмитрий Контрерас...
"Drools: декларативная бизнес-логика в Java-приложениях" by Дмитрий Контрерас..."Drools: декларативная бизнес-логика в Java-приложениях" by Дмитрий Контрерас...
"Drools: декларативная бизнес-логика в Java-приложениях" by Дмитрий Контрерас...
 
Spring.new hope.1.3
Spring.new hope.1.3Spring.new hope.1.3
Spring.new hope.1.3
 
Sql saturday azure storage by Anton Vidishchev
Sql saturday azure storage by Anton VidishchevSql saturday azure storage by Anton Vidishchev
Sql saturday azure storage by Anton Vidishchev
 
Navigation map factory by Alexey Klimenko
Navigation map factory by Alexey KlimenkoNavigation map factory by Alexey Klimenko
Navigation map factory by Alexey Klimenko
 
Serialization and performance by Sergey Morenets
Serialization and performance by Sergey MorenetsSerialization and performance by Sergey Morenets
Serialization and performance by Sergey Morenets
 
Игры для мобильных платформ by Алексей Рыбаков
Игры для мобильных платформ by Алексей РыбаковИгры для мобильных платформ by Алексей Рыбаков
Игры для мобильных платформ by Алексей Рыбаков
 
Async clinic by by Sergey Teplyakov
Async clinic by by Sergey TeplyakovAsync clinic by by Sergey Teplyakov
Async clinic by by Sergey Teplyakov
 
Deep Dive C# by Sergey Teplyakov
Deep Dive  C# by Sergey TeplyakovDeep Dive  C# by Sergey Teplyakov
Deep Dive C# by Sergey Teplyakov
 
Bdd by Dmitri Aizenberg
Bdd by Dmitri AizenbergBdd by Dmitri Aizenberg
Bdd by Dmitri Aizenberg
 
Неформальные размышления о сертификации в IT
Неформальные размышления о сертификации в ITНеформальные размышления о сертификации в IT
Неформальные размышления о сертификации в IT
 
Разработка расширений Firefox
Разработка расширений FirefoxРазработка расширений Firefox
Разработка расширений Firefox
 
"AnnotatedSQL - провайдер с плюшками за 5 минут" - Геннадий Дубина, Senior So...
"AnnotatedSQL - провайдер с плюшками за 5 минут" - Геннадий Дубина, Senior So..."AnnotatedSQL - провайдер с плюшками за 5 минут" - Геннадий Дубина, Senior So...
"AnnotatedSQL - провайдер с плюшками за 5 минут" - Геннадий Дубина, Senior So...
 
Patterns of parallel programming
Patterns of parallel programmingPatterns of parallel programming
Patterns of parallel programming
 
Lambda выражения и Java 8
Lambda выражения и Java 8Lambda выражения и Java 8
Lambda выражения и Java 8
 

Último

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 

Último (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

Android sync adapter

  • 1. DEVELOPING ANDROID CLIENT APPS VIA SYNCADAPTER Anatoliy Kaverin Lohika @ 2013
  • 2. SESSION AGENDA  Why?  SyncAdapter!? LOLWUT?  The big picture  Puzzles  Does anybody use it?  Code samples, documentation  Q&A 2
  • 4. SYNC CACHE: ISSUES TO CONSIDER Are we done?  Global Sync setting  Bandwidth starvation  YES, queued  YES, even duplicates  YES, even if app is off  YES, built in support Hand-made  SyncAdapter framework  Network availability  Pending queue  Refresh on network  Periodic update  YES, manual override  YES! YES! YES! 4
  • 5. SYNCADAPTER!? LOLWUT?  Well, you probably use it everyday… 5
  • 6. THE BIG PICTURE – BASIC FLOW 6
  • 7. THE BIG PICTURE – PUZZLES 7
  • 8. PREREQUISITES TO CONSIDER  Network layer separation  Plain implementation  Sync status field for synced entities  Usually NOOP, Created, Updated & Deleted  Consider the field in UI flows  Consider partial sync  For better performance to sync only local delta 8
  • 9. PUZZLES – ACCOUNT (1)  Key Features  Manage credentials;  Safe system store;  Multitenant support  Sync related  Token caching and invalidation  Alternative flow to login or sign in  Store extra data with account 9
  • 10. PUZZLES – ACCOUNT (2)  Checklist:  Implement Authenticator  Implement Authentication Service  Define configuration in XML 10
  • 11. PUZZLES – ACCOUNT (3)  Checklist:  Register Authentication Service in AndroidManifest  Add permissions  APIs to use:  android.accounts.AccountManager to work with accounts  android.accounts.Account to store credentials 11
  • 12. PUZZLES – CONTENT PROVIDER (1)  Key features  Heart of DAO  Resource effective  Cursor, resource-effective scalability  Power of Joins  Built-in ListView refresh via ContentObserver & Cursor  Sync related  Acts as mediator for sync and UI layers  Supports automatic delta upload sync  NOTE: Can be fake one, but you’ll lose a lot of magic  12
  • 13. PUZZLES – CONTENT PROVIDER (2)  Minimal implementation based on https://github.com/novoda/SQLiteProvider  Supports all CRUD  Supports DB versioning  And even more… 13
  • 14. PUZZLES – SYNCADAPTER (1)  Key features  Plugin to Android SyncManager  SyncManager manages queue of execution  Adapter is executed in background thread & when network is available  Sync related  Scheduling & automated mode  Respects system settings  Can be overridden by manual request  Partial sync supported  Upload only local delta  Any other criteria (Bundle) 14
  • 15. PUZZLES – SYNCADAPTER (2)  Checklist  Implement SyncAdapter class  Implement Sync Service  Define configuration xml 15
  • 16. PUZZLES – SYNCADAPTER (3)  Checklist  Register Sync Service in AndroidManifest  Add permissions  APIs to use  android.content.ContentResolver to reach SyncManager programmatically 16
  • 17. PUZZLES – SYNCADAPTER (4)  How to trigger sync?  Upload delta  ContentResolver.notifyChange  Be aware of cyclic calls if used in ContentProvider  Scheduling  ContentResolver.addPeriodicSync  Automated  ContentResolver.setSyncAutomatically  Manual  ContentResolver.requestSync  Manual forced  ContentResolver.requestSync  Pass SYNC_EXTRAS_MANUAL in bundle 17
  • 18. THE BIG PICTURE – OPTIONAL PUZZLES 18
  • 19. PROS & CONS  Pros  Simplify server interaction  A lot of work handled by framework  Resource effective – the Android way  Cons  A lot of puzzles, hard to start…  Lack of documentation  Error handling  Bugs  19
  • 21. DOCUMENTATION  Official docs  Great tutorial added in August ’13 http://developer.android.com/training/sync- adapters/index.html + code sample  Stackoverflow, use tags below  [android-syncadapter]  [sync] + [android] 21
  • 22. BONUS: CODE SAMPLES  Repo on GitHub https://github.com/springbyexample/spring-by- example  Toy client-server app (both parties supplied )  Shows all puzzles implemented:  Accounts – fake one, there is no authentication  Content Provider based on novoda library  SyncAdapter logics  All wrapping XML configuration  Built via Maven  Follow README and be happy   Got questions?  a.kaverin@gmail.com 22
  • 23. Q & A Thanks for your attention!23