0

Several months I had a problem when I went from one activity to another and I wanted to keep the synchronism with Sphero all the time. The solution was passing the id of the Sphero by Intent and recouping it with the next code:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.OnCreate(savedInstanceState);

    // get the robot object sent through to this Activity
    String robotId = getIntent().getStringExtra("robot.id");
    Robot robot = RobotProvider.getDefaultProvider().findRobot(robotId);
}

I have the same problem because of the Sphero SDK has changed for the model 2.0.

In this API I did the same to pass robotId from a Activity to another (by Intent), but for instancing the robot in the newest Activity, by doing the next code doesn't work:

Robot robot = RobotProvider.getDefaultProvider().findRobot(robotId); Sphero mRobot= (Sphero) robot;

In fact, I have checked if robotId is filled with a correct value and this is correct, but I have null value in robot.

  • To help with debugging, you can query the known robots list by calling `RobotProvider.getDefaultProvider.getRobots()`. Also, a call to `RobotProvider.getDefaultProvider.startDiscovery()` before your `findRobot(robotId)` will clear your robot list. – wes felteau Apr 14 '14 at 00:02
  • RobotProvider.getDefaultProvider.getRobots() appears strikethrough when you use it in API Sphero 2.0, so it doesn't work.But I'm trying anyways ;) – Fernando Prieto Moyano Apr 15 '14 at 12:05
  • See the answer to [this thread](http://stackoverflow.com/questions/18751733/how-to-keep-a-bluetooth-connection-when-sphero-is-synchronized-and-i-use-several/18836065#18836065). – nodnarb May 01 '14 at 06:21

0 Answers0