Your SlideShare is downloading. ×
0
Effective Android Messaging
Juan Gomez
Agenda
• Intro
• HTTP
• WebSockets
• SMS (Text Messages)
• Network Service Discovery
• Review
• Q&A
!2
Eventbrite by the Numbers

Over 2 million events


140 million tickets sold 

$2 billion in gross ticket sales

Events in ...
Intro
Who am I?
• Mobile Engineer at Eventbrite
• Android Developer
• Python enthusiast

!4
Intro
Slides:
• http://lanyrd.com/profile/juandg/
• http://www.andevcon.com/slides

!5
Intro
What do you mean by messaging?
• Communications between devices
• Peer-to-Peer
• Servers are “devices”, and peers to...
Intro
Where do I need messaging:
• IM apps
• Multiplayer games
• Enterprise apps
• Many more…

!7
HTTP
HTTP
• Effective Android HTTP by Jesse Wilson
• Presented at AnDevCon Boston
• http://bit.ly/1auYlY2

!9
HTTP (Native)
HttpURLConnection vs Apache HTTP client
• Apache HTTP client works better on Eclair (2.1)
and Froyo (2.2)
• ...
HTTP (3rd-party)
Volley:
• Great performance and memory mgmt
• Poor documentation and support
OkHttp
• Improved fork of Ht...
HTTP
• It’s not full duplex
• It’s not meant for device peer-to-peer
communication
• Not ideal for low connectivity scenar...
GOOGLE CLOUD MESSAGING

!13
Google Cloud Messaging

!14
Google Cloud Messaging
• Full duplex
• Fire & Forget
• Not always reliable
• No guarantee on time of delivery
• Relatively...
Google Cloud Messaging
Two implementations:
• GCM HTTP
• Based on HTTP Post requests
• Uses JSON messages
• GCM CCS
• Base...
Google Cloud Messaging
Android Studio can implement a simple GCM backend for you, using Google AppEngine
• Follow instruct...
WEB SOCKETS
WebSockets
• Full-duplex communication using Port 80
• Web Server <—> Client
• Not just for Web Browsers
• Near Real-Time
...
WebSockets on Android
• No native Android implementation

!20
Web Sockets (3rd Party)
AutobahnAndroid
• Fully open source
• github.com/tavendo/AutobahnAndroid
• Commercially supported ...
SMS (TEXT MESSAGING)
SMS (Text Messaging)
Pros:
• Asynchronous
• Ideal for low data connectivity
• Only option when there’s no data connectivit...
SMS (Text Messaging)
Cons:
• Asynchronous
• No guarantee of delivery (including order)
• Limited to 160 characters per mes...
SMS (Text Messaging)
When to use them:
• IM apps (duh!)
• Device activation
• Phone number verification
• As a fallback me...
SMS (Text Messaging)
SmsManager
• Sending is really easy
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendT...
SMS (Text Messaging)
Receiving SMS
• It’s an undocumented API
• Implement a BroadCast receiver listening for:
• android.pr...
NETWORK SERVICE DISCOVERY
Network Service Discovery
• Discover services available on the local network
• Based on Apple’s Bonjour
• Multiplatform su...
Network Service Discovery
Alternatives if you’re not on API Level 16 yet:
• Use JmDNS ( jmdns.sourceforge.net)
• Centraliz...
Network Service Discovery
Eventbrite engineering blog:
• engineering.eventbrite.com
• Android NDS Post: http://bit.ly/1aYc...
HOW WE USE IT AT EVENTBRITE?

!32
How we use this at Eventbrite?
Entry Manager
• Paired with a home grown solution called
“Gatekeeper”

!33
How we use this at Eventbrite?
Eventbrite App
• Social Notifications
Push notification when two of your friends are
attend...
We’re hiring!

If you’re interested, let’s talk after the session

eventbrite.com/jobs
Questions?

Download our apps:

eventbrite.com/eventbriteapp
Thank You!
@_juandg
jgomez@eventbrite.com
Upcoming SlideShare
Loading in...5
×

Effective Android Messaging

1,525

Published on

This class intends to guide you by providing an overview of some of the most popular messaging options on the Android Ecosystem, as well as some tips and tricks on how to successfully implement them in your Android apps. We’ll talk about Basic Http messaging, Google’s Cloud Messaging (a.k.a. Push Notifications) and SMS (a.k.a. Text messages), and finally we’ll touch on some newer techniques like Android’s Network Service Discovery (a.k.a. Bonjour) and WebSockets.

Published in: Technology, Business

Transcript of "Effective Android Messaging"

  1. 1. Effective Android Messaging Juan Gomez
  2. 2. Agenda • Intro • HTTP • WebSockets • SMS (Text Messages) • Network Service Discovery • Review • Q&A !2
  3. 3. Eventbrite by the Numbers Over 2 million events
 140 million tickets sold 
 $2 billion in gross ticket sales
 Events in 179 countries
  4. 4. Intro Who am I? • Mobile Engineer at Eventbrite • Android Developer • Python enthusiast !4
  5. 5. Intro Slides: • http://lanyrd.com/profile/juandg/ • http://www.andevcon.com/slides !5
  6. 6. Intro What do you mean by messaging? • Communications between devices • Peer-to-Peer • Servers are “devices”, and peers too ;) !6
  7. 7. Intro Where do I need messaging: • IM apps • Multiplayer games • Enterprise apps • Many more… !7
  8. 8. HTTP
  9. 9. HTTP • Effective Android HTTP by Jesse Wilson • Presented at AnDevCon Boston • http://bit.ly/1auYlY2 !9
  10. 10. HTTP (Native) HttpURLConnection vs Apache HTTP client • Apache HTTP client works better on Eclair (2.1) and Froyo (2.2) • HttpURLConnection is the best choice for Gingerbread (2.3) and above !10
  11. 11. HTTP (3rd-party) Volley: • Great performance and memory mgmt • Poor documentation and support OkHttp • Improved fork of HttpURLConnection (as of 4.0) • Great documentation and support !11
  12. 12. HTTP • It’s not full duplex • It’s not meant for device peer-to-peer communication • Not ideal for low connectivity scenarios (concerts, arenas, etc.) !12
  13. 13. GOOGLE CLOUD MESSAGING !13
  14. 14. Google Cloud Messaging !14
  15. 15. Google Cloud Messaging • Full duplex • Fire & Forget • Not always reliable • No guarantee on time of delivery • Relatively easy to implement !15
  16. 16. Google Cloud Messaging Two implementations: • GCM HTTP • Based on HTTP Post requests • Uses JSON messages • GCM CCS • Based on the XMPP chat protocol • Uses XML messages !16
  17. 17. Google Cloud Messaging Android Studio can implement a simple GCM backend for you, using Google AppEngine • Follow instructions on: • http://googlecloudplatform.blogspot.com/ 2013/06/tutorial-adding-cloud-backend-to-yourapplication-with-android-studio_26.html !17
  18. 18. WEB SOCKETS
  19. 19. WebSockets • Full-duplex communication using Port 80 • Web Server <—> Client • Not just for Web Browsers • Near Real-Time !19
  20. 20. WebSockets on Android • No native Android implementation !20
  21. 21. Web Sockets (3rd Party) AutobahnAndroid • Fully open source • github.com/tavendo/AutobahnAndroid • Commercially supported also Socket.IO client for Android • Fully open source • github.com/koush/android-websockets • Not very well supported !21
  22. 22. SMS (TEXT MESSAGING)
  23. 23. SMS (Text Messaging) Pros: • Asynchronous • Ideal for low data connectivity • Only option when there’s no data connectivity • Mostly free (in the U.S. and Europe) • Supported by “dumb” phones !23
  24. 24. SMS (Text Messaging) Cons: • Asynchronous • No guarantee of delivery (including order) • Limited to 160 characters per message • Android API’s are “mostly” undocumented • Except for the new KitKat API ! !24
  25. 25. SMS (Text Messaging) When to use them: • IM apps (duh!) • Device activation • Phone number verification • As a fallback method for other protocol • As a coordination mechanism !25
  26. 26. SMS (Text Messaging) SmsManager • Sending is really easy SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(“555-123-456“, null, "hello", null, null); ! ! !26
  27. 27. SMS (Text Messaging) Receiving SMS • It’s an undocumented API • Implement a BroadCast receiver listening for: • android.provider.Telephony.SMS_RECEIVED • Bundle contains an array of SmsMessage • Checkout the new KitKat API: • youtu.be/mdq0R2WQssQ !27
  28. 28. NETWORK SERVICE DISCOVERY
  29. 29. Network Service Discovery • Discover services available on the local network • Based on Apple’s Bonjour • Multiplatform support • Android, iOS, OS X, Linux, Windows, Printers, etc. • Only available on API Level 16 and above !29
  30. 30. Network Service Discovery Alternatives if you’re not on API Level 16 yet: • Use JmDNS ( jmdns.sourceforge.net) • Centralized “check-in” Server on fixed IP • DON’T Try to do multicast/broadcast yourself • Not very efficient (really slooow!) • Battery Drain ! ! !30
  31. 31. Network Service Discovery Eventbrite engineering blog: • engineering.eventbrite.com • Android NDS Post: http://bit.ly/1aYc6RN !31
  32. 32. HOW WE USE IT AT EVENTBRITE? !32
  33. 33. How we use this at Eventbrite? Entry Manager • Paired with a home grown solution called “Gatekeeper” !33
  34. 34. How we use this at Eventbrite? Eventbrite App • Social Notifications Push notification when two of your friends are attending the same event . ! !34
  35. 35. We’re hiring! If you’re interested, let’s talk after the session eventbrite.com/jobs
  36. 36. Questions? Download our apps: eventbrite.com/eventbriteapp
  37. 37. Thank You! @_juandg jgomez@eventbrite.com
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×