Professional Documents
Culture Documents
Android Developing RESTful Android Apps
Android Developing RESTful Android Apps
http://bit.ly/bHNnTm
CursorAdapter
Memory Storage
6
CursorAdapter
Service Helper
2. startService(Intent) 10. Binder callback
Service
3. start(param)
Processor
5. start(param)
Content Provider
REST Method
11
6. GET/POST/PUT/DELETE
REST Method
12
REST Method
12
REST Method
12
REST Method
12
REST Method
Enable the gzip content encoding when possible Run the REST method in a worker thread
12
REST Method
Enable the gzip content encoding when possible Run the REST method in a worker thread Use the Apache HTTP client
12
CursorAdapter
Service Helper
2. startService(Intent) 10. Binder callback
Service
3. start(param)
Processor
5. start(param)
Content Provider
REST Method
13
6. GET/POST/PUT/DELETE
Processor
Content Provider
Content Provider
Processor
Content Provider
Content Provider
CursorAdapter
Service Helper
2. startService(Intent) 10. Binder callback
Service
3. start(param)
Processor
5. start(param)
Content Provider
REST Method
16
6. GET/POST/PUT/DELETE
The Service
Service
17
The Service
The role of the service
Service
17
The Service
The role of the service
Service
Forward path: receives the Intent sent by the Service Helper and starts the corresponding REST Method
17
The Service
The role of the service
Service
Forward path: receives the Intent sent by the Service Helper and starts the corresponding REST Method Return path: handles the Processor callback and invokes the Service Helper binder callback
17
The Service
The role of the service
Service
Forward path: receives the Intent sent by the Service Helper and starts the corresponding REST Method Return path: handles the Processor callback and invokes the Service Helper binder callback It can implement a queue of downloads
17
CursorAdapter
Service Helper
2. startService(Intent) 10. Binder callback
Service
3. start(param)
Processor
5. start(param)
Content Provider
REST Method
18
6. GET/POST/PUT/DELETE
Service Helper
19
Service Helper
Singleton which exposes a simple asynchronous API to be used by the user interface
19
Service Helper
Singleton which exposes a simple asynchronous API to be used by the user interface Prepare and send the Service request
Check if the method is already pending Create the request Intent Add the operation type and a unique request id Add the method specific parameters Add the binder callback Call startService(Intent) Return the request id
19
Service Helper
Singleton which exposes a simple asynchronous API to be used by the user interface Prepare and send the Service request
Check if the method is already pending Create the request Intent Add the operation type and a unique request id Add the method specific parameters Add the binder callback Call startService(Intent) Return the request id
CursorAdapter
Service Helper
2. startService(Intent) 10. Binder callback
Service
3. start(param)
Processor
5. start(param)
Content Provider
REST Method
20
6. GET/POST/PUT/DELETE
21
21
21
21
CursorAdapter
Service Helper
2. startService(Intent) 10. Binder callback
Service
3. start(param)
Processor
5. start(param)
Content Provider
REST Method
22
6. GET/POST/PUT/DELETE
Content Provider
2. start(Intent)
Service Helper
3. startService(Intent)
Service
4. start(param)
7. insert/update
REST Method
24
6. Process data
Processor
5. GET/POST/ PUT/DELETE
Content Provider
1.Get items that need to be synced
Sync Adapter
2. start(param)
5. insert/ update/delete
REST Method
3. GET/POST/ PUT/DELETE
4. Process data
Processor
26
Conclusions
The value of an idea lies in the using of it. - Thomas Alva Edison
Conclusions
28
Conclusions
Do not implement REST methods inside Activities
28
Conclusions
Do not implement REST methods inside Activities Start long running operations from a Service
28
Conclusions
Do not implement REST methods inside Activities Start long running operations from a Service Persist early & persist often
28
Conclusions
Do not implement REST methods inside Activities Start long running operations from a Service Persist early & persist often Minimize the network usage
28
Conclusions
Do not implement REST methods inside Activities Start long running operations from a Service Persist early & persist often Minimize the network usage Use a sync adapter to execute background operations which are not time critical
New in Froyo: Android Cloud to Device Messaging
28
http://bit.ly/bHNnTm
29