(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

RosActivity

Description: Building android applications on top of the RosActivity class.

Keywords: rosjava

Tutorial Level: BEGINNER

Next Tutorial: Android Interactions

Here we show how to design your ros android application on top of the fundamental building block - the RosActivity class.


About

TODO

Examples

To Choose or Not to Choose?

There is now an optional way of bypassing the MasterChooser activity in android_core by providing a master URI to the RosActivity constructor.

The Master Chooser

Bundled into android_core is an Activity subclass named MasterChooser. This activity can be used to specify an existing ROS master node or start a new master node on the device. This activity is created and presented in the RosActivity constructor. The view for the MasterChooser contains an EditText field for entering the master node URI as well as a button to connect to the node. There are also some advanced options that can be used when creating a new master node on the device.

It is important to note that the MasterChooser needs to be declared in the application's manifest to avoid a crash. This can be done by adding the following line inside the <application> tag.

  • <activity android:name="org.ros.android.MasterChooser" />

Avoiding the Master Chooser

There are cases where the master node URI can either be hardcoded into the application or it would be best to present a custom view for specifying the master node. This can be accomplished by providing a custom URI in the call to the RosActivity constructor. This will allow the application to use a RosActivity without presenting the MasterChooser.

As an example, to bypass the MasterChooser, the following code from the android_tutorial_pubsub MainActivity:

  • super("Pubsub Tutorial", "Pubsub Tutorial");

would be changed to something similar to:

  • super("Pubsub Tutorial", "Pubsub Tutorial", URI.create("http://localhost:11311"));

Wiki: android/Tutorials/indigo/RosActivity (last edited 2015-03-06 17:21:54 by Rob King)