Ruby conf2012


Published on

Building a SMS based application involves dealing with 3rd party service providers and mobile network operators. As you can imagine, this is time consuming and, given the cost structures in place, expensive. For quick prototypes it isn't worth the hassle. While waiting for your own short code, only hope would keep you together. However, we've seen the tremendous power and reach of SMS - especially for applications around a social theme at ThoughtWorks' Social Impact Program.

EzSMS is our attempt at providing a SMS gateway that can be setup in minutes. Of course it runs on Ruby! All you need is an Android powered phone, a sim-card and data access. Thus it is very easy to prototype your apps. Gone are the days when we, Android owners, would feel alone. With Android activations outpacing births it seems that a hundred billion phones have found homes.

In this talk we'll explore Ruboto and JRuby and quickly explain how to create a simple Android application. We'll explore the internals of our application and then compare Ruboto and other Ruby flavoured mobile app development frameworks. We'll also apologize to Sting for mishearing his song "Message in a bottle" .

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Ruby conf2012

  1. 1. EzSMSA simple SMS gateway for Android in Ruby Chandan Jog Habibullah Pagarkar Anand Agrawal
  2. 2. Chandan Jog
  3. 3. Habibullah Pagarkar @mhabibp
  4. 4. Intended Take-Aways Why SMS?Your options for building an SMS based app Quick introduction to Android A taste of Ruby on Android
  5. 5. SMS is omnipresentLogical choice and not a “hot new” technologyCaters to the technically un-savvy
  6. 6. SMS is powerfulMOTECH and mHealth Suite of services Basic mobile phonesAntenatal and neonatal care
  7. 7. SMS is useful
  8. 8. In the cloud
  9. 9. Or, deal with them
  10. 10. DIY
  11. 11. your grandma get it up?
  12. 12. We <3
  13. 13. We <3
  14. 14. of an Android app
  15. 15. Linux, but not quite Linux kernel + Dalvik VMNo X. No GNU libraries. No JVM.
  16. 16. ActivitiesVisual components
  17. 17. ActivitiesAn application consists of multiple loosely coupled Activities
  18. 18. ActivitiesAn Activity is notified of change in state through application life-cycle callbacks
  19. 19. Views and Layouts Views and Widgets Layout
  20. 20. publ i c class Exam eAc t i vi t y extends Act i vi t y { s pl s @Override e publ i c void onCreate(Bundl e savedInstanceState) { d ) s uper .onCreate(savedInstanceState); ; } @Override e pr ot ect ed void onStart() { d d ) s uper .onStart(); ; } @Override e pr ot ect ed void onResume() { d d ) s uper .onResume(); ; } @Override e pr ot ect ed void onPause() { d d ) s uper .onPause(); ; } @Override e pr ot ect ed void onStop() { d d ) s uper .onStop(); ; } @Override e pr ot ect ed void onDestroy() { d d s uper .onDestroy(); ; ) Activity }}
  21. 21. IntentRoughly analogous to a message
  22. 22. Intent Use Intents to communicatewithin components of an application or between applications
  23. 23. IntentI nt ent intent = new Intent(I nt ent .ACTION_SEND); t t w ;intent.putExtra(I nt ent .EXTRA_EMAIL, recipientArray); , ;startActivity(intent); ;
  24. 24. Intent Filters Explicit IntentsDesignate a target component by its name Implicit Intents Do not name a target
  25. 25. Manifest AndroidManifest.xml Declaratively specify applicationcomponents, services, permissions, minimum Android API version etc.
  26. 26. <manifest xmlns:android="" package=""> <application android:icon="@drawable/app_notes" android:label="@string/app_name" > <provider android:name="NotePadProvider" android:authorities="" /> <activity android:name="NotesList" android:label="@string/title_notes_list"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.EDIT" /> <action android:name="android.intent.action.PICK" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.GET_CONTENT" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="" /> </intent-filter> </activity> </application></manifest>
  27. 27. ServiceBroadcastReceiverContentProvider …
  28. 28.
  29. 29.’s like, too much code, dude! Whoa!
  30. 30. options_from_collection_for_select
  31. 31. Konnichiwa, Ruboto-sanAims to make JRuby a first class Android citizen Lends to easy scripting Maps underlying Android layer
  32. 32. Flavour 1 ruboto-irbInteractive environment on the phone
  33. 33. Flavour 2 ruboto-corePackages Ruby scripts as an APK
  34. 34. Pre-reqs JRubyAndroid SDK Ruboto
  35. 35. Application Generator$ ruboto gen app--package com.yourdomain.whatever--path path/to/app--name AppName--target android-version--min-sdk another-android-version--activity MainActivityName
  36. 36. Class Generator$ ruboto gen classBroadcastReceiver --nameAwesomenessReceiver
  37. 37. Packaging Tasks$ rake install$ rake update_scripts$ rake install:cleanAnd many more with rake -T
  38. 38. Poll BoxA simple feedback gathering application
  39. 39. are we doing?
  40. 40. SMS 08800493714 code Y/N commentezsms Y The talk is awesome!
  41. 41.
  42. 42. is cheap the code We’ll show you
  43. 43. Fork
  44. 44. Good news everyone! Use your existing Ruby knowledge Type less ;) Best of both worlds Android APIs RubyGems
  45. 45. Bad NewsJRuby isn’t designed for constrained devices Stack space limitations on the Dalvik VM Ruboto doesn’t completely abstract away Android’s complexities Slow JRuby start-up time