androidsphero-apisphero

Is there a way to auto connect Sphero in android


I want my app to connect all paired Sphero automatically. I saw there is a class called orbotix.robot.internal.AutoReconnectCommand; but I cannot find any javadoc for this class. Is there a way to auto connect Sphero in android without showing the connection screen?


Solution

  • I found an answer for my own question
    You can use :

    porvider.addConnectionListener(mConnectionListener);
    porvider.addDiscoveryListener(mDiscoveryListener);
    

    For connecting Sphero without using the given GUI from orbotix in the mDiscoverListener you will need to implement a method call onFound.
    In case you have only one robot you can implement it in the following way

    @Override
            public void onFound(List<Sphero> paramList)
            {
                Sphero s=paramList.get(0);
                RobotProvider.getDefaultProvider().connect(s);
            }
    

    If you have more than one robot you can add GUI by yourself for choosing a Sphero