Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 package org.ros.android.my_android_package;
00018
00019 import android.os.Bundle;
00020 import org.ros.android.MessageCallable;
00021 import org.ros.android.RosActivity;
00022 import org.ros.android.view.RosTextView;
00023 import org.ros.node.NodeConfiguration;
00024 import org.ros.node.NodeMainExecutor;
00025 import org.ros.rosjava_tutorial_pubsub.Talker;
00026
00030 public class MainActivity extends RosActivity {
00031
00032 private RosTextView<std_msgs.String> rosTextView;
00033 private Talker talker;
00034
00035 public MainActivity() {
00036
00037
00038 super("Pubsub Tutorial", "Pubsub Tutorial");
00039 }
00040
00041 @SuppressWarnings("unchecked")
00042 @Override
00043 public void onCreate(Bundle savedInstanceState) {
00044 super.onCreate(savedInstanceState);
00045 setContentView(R.layout.main);
00046 rosTextView = (RosTextView<std_msgs.String>) findViewById(R.id.text);
00047 rosTextView.setTopicName("chatter");
00048 rosTextView.setMessageType(std_msgs.String._TYPE);
00049 rosTextView.setMessageToStringCallable(new MessageCallable<String, std_msgs.String>() {
00050 @Override
00051 public String call(std_msgs.String message) {
00052 return message.getData();
00053 }
00054 });
00055 }
00056
00057 @Override
00058 protected void init(NodeMainExecutor nodeMainExecutor) {
00059 talker = new Talker();
00060 NodeConfiguration nodeConfiguration = NodeConfiguration.newPrivate();
00061
00062
00063 nodeConfiguration.setMasterUri(getMasterUri());
00064 nodeMainExecutor.execute(talker, nodeConfiguration);
00065
00066
00067 nodeMainExecutor.execute(rosTextView, nodeConfiguration);
00068 }
00069 }