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
Yuren Ju
October 28, 2012
Programming
5
3.2k
Using Google APIs Client for Android
Yuren Ju
October 28, 2012
Tweet
Share
More Decks by Yuren Ju
See All by Yuren Ju
Taste Cucumber.js - JavaScript BDD Framework
yurenju
0
94
Code For America 見聞錄 - 社會安全網
yurenju
0
110
Impossible Election for recall in Taiwan
yurenju
1
370
物資管理系統與災民證
yurenju
0
790
JavaScript 開發流程自動化懶人包
yurenju
38
5.9k
Code Coverage -- Javascript Frontend + Backend
yurenju
14
7.9k
Loopback + Angular.js
yurenju
3
470
bifrost 物資管理系統
yurenju
4
250
Gaia Build System introduction
yurenju
2
180
Other Decks in Programming
See All in Programming
ファイル先頭の use の意味、説明できますか? 〜PHP の namespace と autoloading の関係を正しく理解しよう〜 / namespace and autoloading in php
okashoi
2
470
フロントエンドパフォーマンス 入門
shouta2
7
1.5k
Kotlinを用いたDSL的な設計手法と使用上の注意
kohii00
3
530
Parallel Socket Communication in Swift
s_shimotori
0
260
Prepare for Jakarta EE 11 - Performance and Developer Productivity
ivargrimstad
0
530
Deep Dive 大規模システムアーキテクチャ/開発組織エンジニアリング / Deep Dive Large-Scale System Architecture, Development Organization Engineering
nrslib
15
2.9k
TCAの Shared Stateって どういう仕組みになってんの?
yimajo
0
330
自動テスト実行結果の目的を整理する / Organizing objectives of automated test results
twada
PRO
10
2.1k
RubyVM を PHP で実装する 〜Hello World を出力するまで〜
memory1994
PRO
1
490
Compiling Python to WebAssembly with py2wasm
syrusakbary
0
140
クソコード動画『カプセル化 Mk-II』 で考える 上手くカプセル化できない理由 / encapsulation2
minodriven
11
8k
IntelliJ IDEA を知らなかった 自分に教えたい小ネタ集 / IntelliJ IDEA Hints for My Past Self
mackey0225
3
180
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
8
8.2k
Principles of Awesome APIs and How to Build Them.
keavy
119
16k
Building a Modern Day E-commerce SEO Strategy
aleyda
15
6.3k
Reflections from 52 weeks, 52 projects
jeffersonlam
343
19k
The Mythical Team-Month
searls
214
42k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
12
1.4k
[RailsConf 2023] Rails as a piece of cake
palkan
21
3.8k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
58
14k
10 Git Anti Patterns You Should be Aware of
lemiorhan
644
57k
Unsuck your backbone
ammeep
661
56k
What's new in Ruby 2.0
geeforr
335
31k
The Invisible Side of Design
smashingmag
293
49k
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