Your SlideShare is downloading. ×
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

18,982

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
18,982
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
137
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
  • 2. Background
    Android is a big step forward in mobile operating systems
    But… Java?
    Dynamic script languages are more productive
    And don’t have to be too slow
    Four main ways to leverage Ruby…
  • 3. Leveraging Ruby for Android
    Scripting: automate phone tasks and testing
    “From scratch” app development
    replace Java
    Framework development
    Less Ruby, compiled Ruby
    App integration
    Full Ruby via server
  • 4. Ruboto
    http://github.com/ruboto
    Ruboto-core
    [sudo] gem install ruboto-core
    Ruboto-core-irb
    Ruboto-demos
    * Ruboto slides here derived from earlier presentations by Daniel Jackoway. Apologies for missing attribution in original post.
  • 5. Android in Ruby
    public void Activity.onCreate(Bundle bundle)
    public void Activity.onPause()
    public void onClick(View view)
    handle_create do |bundle|
    handle_pause do
    handle_click do |view|
  • 6. How It Works
    YourActivity < RubotoActivity < Activity
    • RubotoActivity implements callbacks
    • 7. They tell Ruby to exec blocks, pass params along
  • Ruby for Scripting: IRB
    • http://www.appbrain.com/app/ruboto-irb-%28ruby-on-android%29/org.ruboto.irb
    • 8. Activities only
    • 9. Can’t ship .apk
  • Ruboto-core
  • Ruboto Install
  • Ruboto App Generation
    • $ 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
  • Ruboto App Generation
    • $ 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
  • Ruboto Activity
    • 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’
  • Ruboto Activity (continued)
    • 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
  • Install
    • $ rake install # builds .apk, installs to emulator
    • 45. $ rake; adb -d install -r bin/*-debug.apk
  • Ruby for An App Framework…Rhodes
    Portability
    Write it once and it runs on all smartphones: BlackBerry, iPhone, Windows Mobile, Android, Symbian, Win32
    Leverage Your Web Skills
    Build the app quickly in HTML and Ruby
    Offline Use and Easy Backend Integration
    Work with synchronized local data when offline
    Easily connect to any backend app through web services
    Exploit device capabilities
    GPS, PIM data, camera, push/SMS, native mapping, barcode, signature capture, …
    Enterprise Security Compliant
    Encrypt data on the device, remote wipe of device, secure authentication…
  • 46. Rhodes Architecture
    your app code
    You write:
    RhoSync
    Server
    model
    model
    HTML
    templates
    controller
    Rhodes
    app
    generator
    Backend
    app
    source
    adapter
    model
    model
    HTML
    templates
    controller
    Backend
    app
    source
    adapter
    Rhodes components
    ORM (Rhom)
    Ruby
    executor
    We provide:
    Device
    capabilities
    RhoSync
    client
    Backend
    app
    smartphone device
  • 47. Rhodes vs. Competition
    Only one that supports all devices
    Only one with synchronized data
    Only MVC framework
    First Ruby on the device
    First and only hosted development service for mobile
  • 48. Ruby for App Integration…RhoSync
    [sudo] gem install rhosync
    Write a “source adapter”
    Query
    Create
    Update
    Delete
    Eliminates many tasks in app integration
    No device integration/connection code (assumes in database)
    Removes data storage step
    If its Rails backend, not even source adapter is necessary
    Better user experience
    Data is realtime updated
    No wait for data to be retrieved
  • 49. RhoSync Source Adapter
    rhosync app YourApp
    cdYourApp
    rhosync source Product
    Generates …
    class Product <SourceAdapter
    def query(params=nil)
    # TODO: Query your backend data source and assign the records
    # to a nested hash structure called @result. For example:
    end
    def create(create_hash,blob=nil)
    # TODO: Create a new record in your backend data source
    end
    end
  • 50. RhoHub
    First and only “Development as a Service for mobile”
    More than 10,000 developers signed up in the last year
    ~100 more per day
    Hosted development – WRITE APPS FOR IPHONES FROM WINDOWS
    Web-based IDE for ease of use
    Build for all smartphones online – no need to install SDKs
    Hosted runtime
    No need to set up RhoSync server
    Collaboration
    Work with other developers
    on same project over the web
  • 51. Resources
    • 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

×