Class oriented component definition

donv edited this page Jul 3, 2012 · 4 revisions

Utopia

This page seeks to define the API for defining Activities, Services, BroadcastReceivers and other callback objects using concepts that are as close as possible to the Java way of doing it. We will do this without regarding implementation limitations in the first phase. That will come later.

Activity

require 'ruboto/activity'

class MyActivity
  include Ruboto::Activity

  def on_create
    ...
  end

  def on_resume
    ...
  end

  ...
end

The activity can be started from the declaration in the AndroidManifest using Intent or by starting it programmatically:

require 'ruboto/activity'
require 'my_activity'
start_ruboto_activity(MyActivity.new)

Service

require 'ruboto/service'

class MyService
  include Ruboto::Service

  def on_create
    ...
  end

  def on_start_command
    ...
  end

  ...
end

BroadCastReceiver

require 'ruboto/broadcast_receiver'

class MyBroadcastReceiver
  include Ruboto::BroadcastReceiver

  def on_create
    ...
  end

  def on_receive
    ...
  end

  ...
end

Callbacks

require 'ruboto/callback'

class MyCallBack
  include Ruboto::Callback

  callbacks_for android.opengl.GLSurfaceView.Renderer

  def on_some_event
    ...
  end

  def on_some_other_event
    ...
  end

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