Ruby conf2012

Preview:

DESCRIPTION

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" .

Citation preview

EzSMS

Chandan JogHabibullah Pagarkar

Anand Agrawal

A simple SMS gateway for Androidin Ruby

Chandan Jog@jog_chandan

cjog@thoughtworks.com

Habibullah Pagarkar@mhabibp

hulk@thoughtworks.com

Intended Take-Aways

Why SMS?

Your options for building an SMS based app

Quick introduction to Android

A taste of Ruby on Android

SMS is omnipresent

Logical choice and not a “hot new” technology

Caters to the technically un-savvy

SMS is powerful

MOTECH and mHealthSuite of services

Basic mobile phonesAntenatal and neonatal care

SMS is useful

In the cloud

Or, deal with them

DIY

Can your grandma get it up?

http

://socia

lwebdaily

.com

/wp-co

nte

nt/u

plo

ads/2

01

1/1

2/

gra

ndm

a_m

em

e_la

rge1

.jpg

We <3

We <3

Anatomy of an Android app

http

://waly

ou.co

m/a

ndro

id-e

xplo

ded-

shirt/

Linux, but not quite

Linux kernel + Dalvik VM

No X. No GNU libraries. No JVM.

Activities

Visual components

Activities

An application consists of multipleloosely coupled Activities

Activities

An Activity is notified of change in state

through application life-cycle callbacks

Views and Layouts

Views and Widgets

Layout

Activity

Intent

Roughly analogous to a message

Intent

Use Intents to communicate

within components of an application

or between applications

Intent

Intent Filters

Explicit IntentsDesignate a target component by its

name

Implicit IntentsDo not name a target

Manifest

AndroidManifest.xml

Declaratively specify application components, services, permissions, minimum Android API version etc.

Service

BroadcastReceiver

ContentProvider

Open

DBAdapter.java

Whoa! It’s like, too much code, dude!

http

://aw

eso

mebm

ovie

s.com

/20

11

/04

/bill-a

nd-te

ds-b

ack

-in-a

ction/

options_from_collection_for_select

Konnichiwa, Ruboto-san

Aims to make JRuby a first class Android citizen

Lends to easy scripting

Maps underlying Android layer

Flavour 1

ruboto-irb

Interactive environment on the phone

Flavour 2

ruboto-core

Packages Ruby scripts as an APK

Pre-reqs

JRuby

Android SDK

Ruboto

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

Class Generator

$ ruboto gen class BroadcastReceiver --name AwesomenessReceiver

Packaging Tasks

$ rake install

$ rake update_scripts

$ rake install:clean

And many more with rake -T

Poll Box

A simple feedback gathering application

http://Poll-Box.com

http

://ww

w.ca

ribdire

ct.com

/20

12

/01

/31

/how

s-my-d

rivin

g-to

o-fa

st-too-b

ad/

How are we doing?

SMS 08800493714

code Y/N comment

ezsms Y The talk is awesome!

poll-box.com/response/102/ezsms

Talk is cheap

We’ll show youthe code

http

://en.w

ikipedia

.org

/wik

i/Linus_T

orv

ald

s

Fork it

github.com/chandanjog/ez_sms

Good news everyone!

Use your existing Ruby knowledge

Type less ;)

Best of both worldsAndroid APIs

RubyGems

http

://holly

woodhate

sme.fi

les.w

ord

pre

ss.com

/20

11

/09

/pro

f-farn

sworth

.jpg

Bad News

JRuby 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

Recommended