Upload
nacef-labidi
View
10
Download
0
Embed Size (px)
DESCRIPTION
Few slides presented during Droidcon Tunisia 2014 about using resftul webservices to connect Andrid app to your server side backend
Citation preview
1Nacef LABIDIConnect your app to your backend
Connect your app to your backend
Presented by Nacef LABIDIMarch 2014
2
Who I am ?
• System Level Developer @ STMicroelectronics• Co-founder and Technical Manager @ Oceanys• Project Manager @ Evatys• Technical Consultant @ Hewlett-Packard• IT Manager @ US Peace Corps• Global Helpdesk Manager @ Vistaprint
3
Who I really am ? ;)
• Computer engineer, geek and music addict.• Open Source enthusiast, supporter and
contributor.• Android apps developer (when I find some time)• Python fan and supporter.• Speak many programming languages.
4
Audience
• Beginners in Android development• People wanting to build mobile apps around
dynamic content• Building multi-platform mobile apps
5
Storing your data inside vs. outside of your app• Pros
• Decoupling between the app and the data• Keeping the logic on the server side
• Makes your apps lighter• Makes your logic consistent and reusable
• Evolution of your service relies more on the data than the app itself.
• Publish your data to multiple medias : Website, all kind of mobile devices, share your data with affiliates
6
Storing your data inside vs. outside of your app• Cons
• Need to be connected to access the data• This can be improved by caching some of the
data locally
• Delays in treatment depending on the volume of data and the quality of the connection
• May expose your data to some security risks• Again this can be addressed
7
How would I proceed ?
• If you don’t have a backend, start by building one• This will help you define the structure of the
data that you want to expose in your app• Designing the data will also help you design the
layout of your app• Build a webservice API that will be used to
access the data• Secure your webservice
8
Building your backend
• Choose the right tools : modern frameworks• Define your data structures• Use migrations to evolve your data structures
without messing with your data• Use RESTful capabilities of your framework to
publish your data to your app• Choose the exchange format that suits you
most (XML, JSON…)• Use security capabilities to protect your data
9
Secure your backend
• Different security methods :– HTTP Basic Authentication
• Login and password sent with the HTTP request– ApiKey Authentication
• Passing an ApiKey generated on the server side in each HTTP request
– OAuth Authentication• Through a third party authentication service
(Google, Facebook, Yahoo, OpenID …)– Create your custom authentication system
• Public/Private RSA keys• …
10
My personal choices
• Python language• http://www.python.org
• Django framework https://www.djangoproject.com• Provides Model classes• Supports many DB backends (Relational &
NoSQL)
• Migrations: through South module http://south.aeracode.org
• RESTful API: through Tastypie module http://tastypieapi.org
11
Build your app
• Use Apache HTTP Client classes
• Use Google Gson to map API responses to your local objects• https://code.google.com/p/google-gson
• Use AsyncTask to keep your app responsive while retrieving your data from the server
• Goodies : You should try RoboGuice to have a nicely architected app• https://github.com/roboguice/roboguice
12
Retrospective
• Tunibus : An android app allowing users to find their way through the Tunis public transportation (Bus, Metro, Train …)– Neo4j Graph database representing stations
and edges representing transportation lines connecting the stations. http://www.neo4j.org
– RESTful webservice that returns the possible paths between two points
– Android app that connects through the API to the Graph DB
– Crowdsourcing web app to enhance the data quality
13
Retrospective
RESTful API
14
Thank you !
Questions ?