コード例 #1
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mSpheroConnectionView = (SpheroConnectionView) findViewById(R.id.sphero_connection_view);
    mSpheroConnectionView.addConnectionListener(
        new ConnectionListener() {

          @Override
          public void onConnected(Robot robot) {
            // SpheroConnectionView is made invisible on connect by default
            mRobot = (Sphero) robot;
          }

          @Override
          public void onConnectionFailed(Robot sphero) {
            // let the SpheroConnectionView handle or hide it and do something here...
          }

          @Override
          public void onDisconnected(Robot sphero) {
            mSpheroConnectionView.startDiscovery();
          }
        });
  }
コード例 #2
0
 /** Called when the user comes back to this app */
 @Override
 protected void onResume() {
   super.onResume();
   // Refresh list of Spheros
   mSpheroConnectionView.startDiscovery();
 }