Android client-server applications
Motivation: § Data loading; § Data sharing; § Communication;
We should have: § Server side; § Client side; § Communication between server side and client side (RESTful API);
Server side: § Database; § API;
Client side: § § Server module (process all the data); UI module – uses server module to get, update and send data and interact with the user;
Server module: § § § § Send requests to server and read answers; Provides API for UI module; Take care about all the data; Take care about asynchronously processing requests; Cashes all data; Stable; Scalable;
UI module: § § § Uses server module to get data; Communicate with server module with callbacks mechanism; Should always be responsive;
Server module
Send requests to server and read answers
Standard way
Deprecated way – Apache Http classes – deprecated since API 22
Now let’s start creating some good architecture
Server side example
Store and cache all data, providing API
UI module
Processing requests asynchronously: § § § Threads + Runnables + Handler; Async. Task + Callbacks; Loaders; Services + Broadcast. Receivers; Volley framework; Rx. Java;
Async. Task
Using API
Sending requests and getting answers
Security
APK files are easy as any jar files are easy to decomplie. So, you just because of it cannot achieve perfect secrecy and even enough secrecy. Any key, any password for you API you should provide as a string in your. apk file. So, it easy to get it.
Tools to decompile your app: § § Show. Java – simple android application, which can decompile any installed or given apk and show only the java code; Apktool – powerful tool, which allows you to get a Java code, resources files and etc. ;
§ § § How to protect: Use some existing API for authorization and etc. , such as Google+ Auth. Use confirmation for sensitive actions (later); Store sensitive data with cryptography tools. Use public-key cryptography for exchanging. Use Pro. Guard – obfuscation.
Pro. Guard