Ask Your Question

Skip Master Chooser

asked 2013-02-21 02:12:14 -0500

dberm22 gravatar image

updated 2014-01-28 17:15:21 -0500

ngrennan gravatar image

I am developing an android app with rosjava, and I am setting the Master URI programatically. Therefore, the Master Chooser screen does nothing for me. Is there a way I can skip it totally?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2013-02-25 04:31:26 -0500

dberm22 gravatar image

Thanks to Kazuto for the lead, but there are a few issues with his answer. I was able to solve them with the included code. First, I changed startMasterChooser in to public, and then pasted this code into my activity:

  public void startMasterChooser() {

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    String masterURI = prefs.getString("masterURI", "");

    Intent data = new Intent();
    data.putExtra("ROS_MASTER_URI", masterURI);
    onActivityResult(0, RESULT_OK, data);


Alternatively, you can just hardcode the masterURI...I chose to have it as a preference. Hopefully changing the RosActivity code doesn't have any effect on future work.

edit flag offensive delete link more


I think this is better solution because it can work well without adding a new global variable.

KazutoMurase gravatar image KazutoMurase  ( 2013-02-25 05:13:30 -0500 )edit

answered 2013-02-21 08:41:51 -0500

KazutoMurase gravatar image

Master Chooser is called in the startMasterChooser() method, and this method is public. So you can override it in your original activity class.

For example:

public void startMasterChooser() {
        URI uri;
        try {
            uri = new URI(ROS_MASTER_URI);
        } catch (URISyntaxException e) {
            throw new RosRuntimeException(e);

        new AsyncTask<Void, Void, Void>() {
            protected Void doInBackground(Void... params) {
                return null;

ROS_MASTER_URI is your fixed URI.

CustomActivity is your original activity class.

edit flag offensive delete link more


Few issues. First, startMasterChooser is private. You have to change that in the gingerbread package. Second, nodeMainExecutor cannot be accessed this way. More changes would have to be made the RosActivity file. Instead, you can do what I did...see my solution.

dberm22 gravatar image dberm22  ( 2013-02-25 01:12:39 -0500 )edit

Oh, you are right, I forget changing my RosActivity class and making nodeMainExecutorService global before, I'm sorry! Actually, my program works well with above codes.

KazutoMurase gravatar image KazutoMurase  ( 2013-02-25 05:06:21 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-02-21 02:12:14 -0500

Seen: 990 times

Last updated: Feb 25 '13