public void connect(KrollDict args) throws RuntimeException {
   if (device == null) {
     // this.getCapabilityToken(args.get("url").toString());
     PendingIntentProxy proxy = (PendingIntentProxy) args.get("pendingIntent");
     PendingIntent pendingIntent = proxy.getPendingIntent();
     this.getCapabilityToken(args.get("url").toString(), pendingIntent);
   }
   if (args.containsKey("params") && args.get("params") instanceof HashMap) {
     HashMap<String, String> params = (HashMap<String, String>) args.get("params");
     Map<String, String> parameters = new HashMap<String, String>();
     for (String key : params.keySet()) {
       parameters.put(key, params.get(key).toString());
     }
     connection = device.connect(parameters, null);
   } else {
     connection = device.connect(null, null);
   }
 }
  public void connect() {
    if (connection == null || connection.getState() == Connection.State.DISCONNECTED) {
      connection = device.connect(null /* parameters */, null /* ConnectionListener */);
    } else {
      // Already connected!
      Log.v(LOGTAG, "Already connected!");
    }

    if (connection == null) {
      Log.v(LOGTAG, "Failed to create new connection");
    }
  }