14
EREST Client by Eugen Arbuleac & Laurentiu Onac

Droidcon Eastern Europe 2013 - Efficient REST client Android applications

Embed Size (px)

DESCRIPTION

Best practices when using REST clients in Java for Android presented by Eugeniu Arbuleac and Laurentiu Onac - Appsrise.com . The slides were presented at Droidcon Bucharest 2013.

Citation preview

Page 1: Droidcon Eastern Europe 2013 - Efficient REST client Android applications

Efficient

REST Clientapplications

by

Eugen Arbuleac & Laurentiu Onac

Page 2: Droidcon Eastern Europe 2013 - Efficient REST client Android applications

What is

REST?

Page 3: Droidcon Eastern Europe 2013 - Efficient REST client Android applications

What is REST?

client server architectural style1

2

3

4

exchanges resources

broadly adopted

commonly used over http

Page 4: Droidcon Eastern Europe 2013 - Efficient REST client Android applications

Mobile friendly web pages

VSREST Mobile apps

Page 5: Droidcon Eastern Europe 2013 - Efficient REST client Android applications

Apps advantages OVER Web sites

integration with the platform1

2

3

4

Run in background

Consistent UI

users prefer native apps

Page 6: Droidcon Eastern Europe 2013 - Efficient REST client Android applications

WrongAPPROACH

Page 7: Droidcon Eastern Europe 2013 - Efficient REST client Android applications

Wrong Approach

Activity - UI thread

Worker thread

REST Request

Page 8: Droidcon Eastern Europe 2013 - Efficient REST client Android applications

Wrong Approach

Limited memory

No persistence

21

Page 9: Droidcon Eastern Europe 2013 - Efficient REST client Android applications

GoodAPPROACH

Page 10: Droidcon Eastern Europe 2013 - Efficient REST client Android applications

Good Approach

Activity - UI thread

Service - UI thread

Content provider

Handler

Crud

NOTIFY

initiate rest request

Worker thread

REST Request

Content observer

Response

parser

service helper

callback

RESOURCE STATE UPDATE

Page 11: Droidcon Eastern Europe 2013 - Efficient REST client Android applications

Good Approach

Use services

1Use

worker threads

2

3Use

content providers

Page 12: Droidcon Eastern Europe 2013 - Efficient REST client Android applications

Even better Approach

Use push notifications

4

notify new dataserver

Page 13: Droidcon Eastern Europe 2013 - Efficient REST client Android applications

Even better Approach

Content provider

Sync adapter

Use Sync adapter

5

server

1. requestsyncdata

Handler

2. PASS sync data

3. INIT Request

4. Response

5. parse6. CRUD