Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Using Google APIs Client for Android
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Yuren Ju
October 28, 2012
Programming
3.3k
5
Share
Using Google APIs Client for Android
Yuren Ju
October 28, 2012
More Decks by Yuren Ju
See All by Yuren Ju
Taste Cucumber.js - JavaScript BDD Framework
yurenju
0
180
Code For America 見聞錄 - 社會安全網
yurenju
0
240
Impossible Election for recall in Taiwan
yurenju
1
510
物資管理系統與災民證
yurenju
0
1k
JavaScript 開發流程自動化懶人包
yurenju
38
6.1k
Code Coverage -- Javascript Frontend + Backend
yurenju
14
8.1k
Loopback + Angular.js
yurenju
3
590
bifrost 物資管理系統
yurenju
4
310
Gaia Build System introduction
yurenju
2
210
Other Decks in Programming
See All in Programming
Reactive ❤️ Loom: A Forbidden Love Story
franz1981
2
210
How to stabilize UI tests using XCTest
akkeylab
0
150
AI-DLC 入門 〜AIコーディングの本質は「コード」ではなく「構造」〜 / Introduction to AI-DLC: The Essence of AI Coding Is Not “Code” but “Structure”
seike460
PRO
0
140
モダンOBSプラグイン開発
umireon
0
190
年間50登壇、単著出版、雑誌寄稿、Podcast出演、YouTube、CM、カンファレンス主催……全部やってみたので面白さ等を比較してみよう / I’ve tried them all, so let’s compare how interesting they are.
nrslib
4
570
RailsのValidatesをSwift Macrosで再現してみた
hokuron
0
140
AWS×クラウドネイティブソフトウェア設計 / AWS x Cloud-Native Software Design
nrslib
16
3.5k
モックわからないマン卒業記 ~振る舞いを起点に見直した、フロントエンドテストにおけるモックの使いどころ~
tasukuwatanabe
3
430
Agentic AI: Evolution oder Revolution
mobilelarson
PRO
0
220
Xdebug と IDE による デバッグ実行の仕組みを見る / Exploring-How-Debugging-Works-with-Xdebug-and-an-IDE
shin1x1
0
290
飯MCP
yusukebe
0
440
実践ハーネスエンジニアリング #MOSHTech
kajitack
7
5.2k
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
432
67k
Darren the Foodie - Storyboard
khoart
PRO
3
3.1k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
64
53k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.1k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.2k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
110
Balancing Empowerment & Direction
lara
5
1k
Docker and Python
trallard
47
3.8k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Facilitating Awesome Meetings
lara
57
6.8k
Transcript
別再手刻 APIs Client 了 使用 Google APIs Client for Android
Yuren Ju
Yuren Ju • Open Source Community – Kalug – COSCUP
– Hacking Thursday • Open Source Developer – Lazyscripts – Ubuntu 懶人包 – Mozilla Firefox OS • Android Developer
Web service API
有很多種路可以走 ... • 手刻 – HttpGet/HttpPost • Restlet • Google
APIs Client for Java! http://www.flickr.com/photos/fractalthoughts/4903092759/in/photostream/
Implementing an API method • Build URL • Get content
(GET/POST) • Convert to object
手刻 http://www.flickr.com/photos/carnivillain/2048440745/
Building URL
Getting Content (GET)
Getting Content (POST) http://blog.csdn.net/flying_tao/article/details/6553601
Converting to object
Google APIs Client Library for Java
None
Example http://<DOMAIN-NAME>/api/emails/
[email protected]
verifyEmail(“819284”, “
[email protected]
”).execute();
Implementing an API method
Parameters Mapping http://<DOMAIN-NAME>/api/emails/
[email protected]
GET v.s. POST
POST
Preconditions
Implementing an API method
Getting started! http://code.google.com/p/google-api-java-client/wiki/Setup
Example service
.jar files
No!!!!!!!
None
Create API Client
Use Builder pattern
HttpRequestInitializer
Create Model
Implement the API
比較 • Get content (GET/POST) • Convert to object •
Preconditions • Parameter mapping/Build URL
OAuth https://github.com/yurenju/AndroidTwitterGoogleApiJavaClient
Attention! Use xAuth on mobile! OAuth experience with pin code
isn't good on mobile https://dev.twitter.com/docs/oauth/xauth
Android app Twitter OAuthGetTemporaryToken OAuthAuthorizeTemporaryTokenUrl Listen OnLoadPageFinished and parse pin
code in webpage Enter username and password Show pin code Done!
OAuthGetTemporaryToken
OAuthAuthorizeTemporaryTokenUrl
None
Parse pin code in webview Don't do it on your
production app, please use xAuth
Conclusion • Build URL • Handle POST/GET Method • Preconditions
• Android, GAE and Java SE Compatibility
FAQ