Using Ruby in Android Development
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

Using Ruby in Android Development

  • 19,658 views
Uploaded 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)

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
19,658
On Slideshare
19,457
From Embeds
201
Number of Embeds
10

Actions

Shares
Downloads
131
Comments
0
Likes
11

Embeds 201

http://www.igneousquill.net 155
http://www.adamgonnerman.com 31
url_unknown 5
http://www.tumblr.com 4
http://paper.li 1
http://feeds.feedburner.com 1
http://us-w1.rockmelt.com 1
http://www.slideshare.net 1
http://igneousquill.info 1
http://twitter.com 1

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