|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.|
RosActivityDescription: Building android applications on top of the RosActivity class.
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.
To Choose or Not to Choose?
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.
super("Pubsub Tutorial", "Pubsub Tutorial");
would be changed to something similar to:
super("Pubsub Tutorial", "Pubsub Tutorial", URI.create("http://localhost:11311"));