Esempio n. 1
0
  private void downloadImage() {
    String myURL = equip.getImage_url();

    try {
      URL url = new URL(myURL);
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      bitmap = BitmapFactory.decodeStream(conn.getInputStream());
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
    protected Void doInBackground(Void... params) {
      String outString;
      HttpURLConnection c = null;
      DataOutputStream os = null;

      outString = scanData.getOwnBSSID();
      outString = outString + "\nL\tX\t" + lastLat + "\t" + lastLon + "\n";

      try {
        URL connectURL = new URL("http://www.openwlanmap.org/android/upload.php");
        c = (HttpURLConnection) connectURL.openConnection();
        if (c == null) {
          return null;
        }

        c.setDoOutput(true); // enable POST
        c.setRequestMethod("POST");
        c.addRequestProperty("Content-Type", "application/x-www-form-urlencoded, *.*");
        c.addRequestProperty("Content-Length", "" + outString.length());
        os = new DataOutputStream(c.getOutputStream());
        os.write(outString.getBytes());
        os.flush();
        c.getResponseCode();
        os.close();
        outString = null;
        os = null;
      } catch (IOException ioe) {
      } finally {
        try {
          if (os != null) os.close();
          if (c != null) c.disconnect();
        } catch (IOException ioe) {
          ioe.printStackTrace();
        }
      }
      return null;
    }