Your SlideShare is downloading. ×
0
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Using Ruby in Android Development
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Using Ruby in Android Development

19,172

Published on

Discusses four tools that can be used to build Android smartphone apps. Specifically IRB for scripting on the device, Ruboto for building arbitrary apps, Rhodes (a framework which includes a fast …

Discusses four tools that can be used to build Android smartphone apps. Specifically IRB for scripting on the device, Ruboto for building arbitrary apps, Rhodes (a framework which includes a fast compiled Ruby) and RhoSync (a mobile app integration server which uses Ruby)

Published in: Technology
0 Comments
11 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
19,172
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
138
Comments
0
Likes
11
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Using Ruby for AndroidDevelopment<br />
  • 2. Background<br />Android is a big step forward in mobile operating systems<br />But… Java?<br />Dynamic script languages are more productive<br />And don’t have to be too slow<br />Four main ways to leverage Ruby…<br />
  • 3. Leveraging Ruby for Android<br />Scripting: automate phone tasks and testing<br />“From scratch” app development <br />replace Java<br />Framework development<br />Less Ruby, compiled Ruby<br />App integration<br />Full Ruby via server<br />
  • 4. Ruboto<br />http://github.com/ruboto<br />Ruboto-core<br />[sudo] gem install ruboto-core<br />Ruboto-core-irb<br />Ruboto-demos<br />* Ruboto slides here derived from earlier presentations by Daniel Jackoway. Apologies for missing attribution in original post. <br />
  • 5. Android in Ruby<br />public void Activity.onCreate(Bundle bundle)<br />public void Activity.onPause()<br />public void onClick(View view)<br />handle_create do |bundle|<br />handle_pause do<br />handle_click do |view|<br />
  • 6. How It Works<br />YourActivity < RubotoActivity < Activity<br /><ul><li>RubotoActivity implements callbacks
  • 7. They tell Ruby to exec blocks, pass params along</li></li></ul><li>Ruby for Scripting: IRB<br /><ul><li>http://www.appbrain.com/app/ruboto-irb-%28ruby-on-android%29/org.ruboto.irb
  • 8. Activities only
  • 9. Can’t ship .apk</li></li></ul><li>Ruboto-core<br /><ul><li>Goals
  • 10. Anything you can do with Java
  • 11. Zero Java
  • 12. Zero XML
  • 13. Support plugins</li></li></ul><li>Ruboto Install<br /><ul><li>JDK
  • 14. JRuby (rvm)
  • 15. Android SDK
  • 16. Generate an emulator
  • 17. gem install ruboto-core</li></li></ul><li>Ruboto App Generation<br /><ul><li>$ ruboto gen app
  • 18. $ --package com.adamblum.andevcon
  • 19. $ --path andevcon # where app files go
  • 20. $ --name andevcon # Name of app
  • 21. $ --target android-8 # Froyo
  • 22. $ --activity MyActivity # Name of Activity</li></li></ul><li>Ruboto App Generation<br /><ul><li>$ ruboto gen app
  • 23. $ --package com.adamblum.andevcon
  • 24. $ --path andevcon # where app files go
  • 25. $ --name andevcon # Name of app
  • 26. $ --target android-8 # Froyo
  • 27. $ --activity MyActivity # Name of Activity</li></li></ul><li>Ruboto Activity<br /><ul><li>assets/scripts/my_activity.rb
  • 28. require 'ruboto.rb’
  • 29. ruboto_import_widgets :TextView,
  • 30. :LinearLayout, :Button
  • 31. $activity.handle_create do |bundle|
  • 32. setTitle 'This is the Title’</li></li></ul><li>Ruboto Activity (continued)<br /><ul><li>setup_content do
  • 33. linear_layout :orientation => LinearLayout::VERTICAL do
  • 34. @text_view = text_view :text => "What hath Matz wrought?"
  • 35. button :text => "M-x butterfly", :width => :wrap_content
  • 36. end
  • 37. end
  • 38. handle_click do |view|
  • 39. if view.getText == 'M-x butterfly'
  • 40. @text_view.setText "What hath Matz wrought!"
  • 41. toast 'Flipped a bit via butterfly'
  • 42. end
  • 43. end
  • 44. end</li></li></ul><li>Install<br /><ul><li>$ rake install # builds .apk, installs to emulator
  • 45. $ rake; adb -d install -r bin/*-debug.apk</li></li></ul><li>Ruby for An App Framework…Rhodes<br />Portability<br />Write it once and it runs on all smartphones: BlackBerry, iPhone, Windows Mobile, Android, Symbian, Win32<br />Leverage Your Web Skills<br />Build the app quickly in HTML and Ruby<br />Offline Use and Easy Backend Integration<br />Work with synchronized local data when offline<br />Easily connect to any backend app through web services<br />Exploit device capabilities<br />GPS, PIM data, camera, push/SMS, native mapping, barcode, signature capture, …<br />Enterprise Security Compliant<br />Encrypt data on the device, remote wipe of device, secure authentication…<br />
  • 46. Rhodes Architecture<br />your app code<br />You write:<br />RhoSync<br />Server<br />model<br />model<br />HTML <br />templates<br />controller<br />Rhodes<br />app<br />generator<br />Backend<br />app<br />source<br />adapter<br />model<br />model<br />HTML <br />templates<br />controller<br />Backend<br />app<br />source<br />adapter<br />Rhodes components<br />ORM (Rhom)<br />Ruby<br />executor<br />We provide:<br />Device<br />capabilities<br />RhoSync <br />client<br />Backend<br />app<br />smartphone device<br />
  • 47. Rhodes vs. Competition<br />Only one that supports all devices<br />Only one with synchronized data<br />Only MVC framework<br />First Ruby on the device<br />First and only hosted development service for mobile<br />
  • 48. Ruby for App Integration…RhoSync<br />[sudo] gem install rhosync<br />Write a “source adapter” <br />Query<br />Create<br />Update <br />Delete<br />Eliminates many tasks in app integration<br />No device integration/connection code (assumes in database)<br />Removes data storage step<br />If its Rails backend, not even source adapter is necessary<br />Better user experience<br />Data is realtime updated<br />No wait for data to be retrieved<br />
  • 49. RhoSync Source Adapter<br />rhosync app YourApp<br />cdYourApp<br />rhosync source Product<br />Generates …<br />class Product <SourceAdapter<br />def query(params=nil)<br /> # TODO: Query your backend data source and assign the records <br /> # to a nested hash structure called @result. For example:<br />end<br /> def create(create_hash,blob=nil)<br /> # TODO: Create a new record in your backend data source<br />end<br />end<br />
  • 50. RhoHub<br />First and only “Development as a Service for mobile”<br />More than 10,000 developers signed up in the last year<br />~100 more per day<br />Hosted development – WRITE APPS FOR IPHONES FROM WINDOWS<br />Web-based IDE for ease of use<br />Build for all smartphones online – no need to install SDKs<br />Hosted runtime<br />No need to set up RhoSync server<br />Collaboration <br />Work with other developers <br />on same project over the web<br />
  • 51. Resources<br /><ul><li>http://github.com/ruboto
  • 52. http://docs.rhomobile.com
  • 53. http://rhomobile.com/products/rhodes
  • 54. http://rhomobile.com/products/rhosync
  • 55. http://rhohub.com
  • 56. adam@rhomobile.com</li></li></ul><li>

×