Example: Open a web page

cjbcross edited this page Jan 28, 2014 · 9 revisions

Example: Open a web page

Our goal

Display a web page when the application is started.

Prerequisites

  • You should have completed the Getting started with Ruboto tutorial.
  • A connected Android device or emulator with an internet connection.

This tutorial has been tested with the following setups

Platform JDK ant Ruby ruboto jruby-jars Device API level Tester
OS X 10.8.0 1.6.0_33 1.8.2 MRI 1.8.7 0.8.0 HTC Desire HD android-10 donv

Generate, install, and start your app

ruboto gen app --package org.ruboto.examples.ruboto_home_page
cd ruboto_home_page
rake install start

You should see an application called "Ruboto Home Page" in your application list on the device. You should eventually get "What hath Matz wrought?" and a button. Clicking the button displays a short notification (toast) "Flipped a bit via butterfly".

A fresh app

Display the web page when the app is started

Edit the file src/ruboto_home_page_activity.rb to this:

import "android.content.Intent"
import "android.net.Uri"

class RubotoHomePageActivity
  def on_create(bundle)
    super
  end

  def on_resume
    super
    intent = Intent.new(Intent::ACTION_VIEW)

    intent.setData(Uri.parse("http://ruboto.org/"))
    startActivity(intent)
    finish
  end
end

Update and start the app

rake install start

After the app has started, it should display the Ruboto home page.

Ruboto Home Page

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.