This document discusses Rhodes and PhoneGap, which are frameworks for building cross-platform mobile apps using HTML, CSS, and JavaScript. Rhodes uses Ruby on the backend and generates HTML/CSS/JS for the frontend. It has an MVC architecture with the model on a web server and the view/controller on the device. PhoneGap is a thin layer that allows HTML/JS apps to access native device capabilities like contacts and geolocation through JavaScript bridges. It works by loading an HTML file into a native Android app container. Both frameworks allow writing code once that can run on multiple mobile platforms.
13. How does Rhodes work?
• MVC => Model on Web(RhoSync as Rails
app) and VC on Device (Rhodes)
• Ruby(XRuby for Android) for business
logic and data access
• Generates HTML via Erb (Embedded Ruby)
• ORM => Key&value pair(Rhom)
new bamboo
21. How does PhoneGap
work(for Android)?
• Very thin layer on top of skeleton project
• appView.setJavaScriptEnabled
• appView. addJavascriptInterface(gap, "Device");
• appView.loadUrl(this.uri)
new bamboo
22. Source - DroidGap.java
public class DroidGap extends Activity {
private static final String LOG_TAG = "DroidGap";
private WebView appView;
private String uri;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
appView = (WebView) findViewById(R.id.appView);
appView.setWebChromeClient(new GapClient(this));
appView.getSettings().setJavaScriptEnabled(true);
appView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
bindBrowser(appView);
new bamboo
23. Source - DroidGap.java
private void bindBrowser(WebView appView)
{
// The PhoneGap class handles the Notification and Android Specific crap
PhoneGap gap = new PhoneGap(this, appView);
GeoBroker geo = new GeoBroker(appView, this);
AccelListener accel = new AccelListener(this, appView);
// This creates the new javascript interfaces for PhoneGap
appView.addJavascriptInterface(gap, "Device");
appView.addJavascriptInterface(geo, "Geo");
appView.addJavascriptInterface(accel, "Accel");
}
new bamboo
24. Source - PhoneGap.java
public class PhoneGap{
private static final String LOG_TAG = "PhoneGap";
/*
* UUID, version and availability
*/
....
public void beep(long pattern)
{
RingtoneManager beeper = new RingtoneManager(mCtx);
Uri ringtone = beeper.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone notification = beeper.getRingtone(mCtx, ringtone);
notification.play();
}
new bamboo
32. More Info(Rhodes)
• Screencast http://www.youtube.com/rhomobile
• Rhomobile web site http://rhomobile.com
• Google group http://groups.google.com/group/rhomobile
• My blog http://rubyonmobile.wordpress.org
• Apps on Market http://rhomobile.com/customers
new bamboo
33. More Info(PhoneGap)
• web site http://phonegap.com/
• Google group http://groups.google.com/group/phonegap
• Screencast http://tinyurl.com/nl3bvx
• Apps on market http://phonegap.com/projects
new bamboo