public String getTemp(String Sdate, String Stime) {
    for (int i = 0; i < list.length(); i++) {
      try {
        JSONObject listItem = list.getJSONObject(i);
        SimpleDateFormat form = new SimpleDateFormat("MMMM dd, yyyy.hh:mma");
        java.util.Date date = null;
        try {
          date = form.parse(Sdate + "." + Stime);
        } catch (ParseException e) {

          e.printStackTrace();
        }
        SimpleDateFormat postFormater = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String newDateStr = postFormater.format(date);
        //				Log.d("OUT", "main: "+newDateStr+", owm: "+listItem.getString("dt_txt"));
        if (listItem.getString("dt_txt").equals(newDateStr)) {
          if (i > 0) {
            double d =
                Double.parseDouble(listItem.getJSONObject("main").getString("temp")) - 273.15;
            return String.valueOf(d);
          }
        }
      } catch (Exception e) {
      }
    }
    return null;
  }
  /**
   * Read location information from image.
   *
   * @param imagePath : image absolute path
   * @return : loation information
   */
  public Location readGeoTagImage(String imagePath) {
    Location loc = new Location("");
    try {
      ExifInterface exif = new ExifInterface(imagePath);
      float[] latlong = new float[2];
      if (exif.getLatLong(latlong)) {
        loc.setLatitude(latlong[0]);
        loc.setLongitude(latlong[1]);
      }
      String date = exif.getAttribute(ExifInterface.TAG_DATETIME);
      SimpleDateFormat fmt_Exif = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
      try {
        loc.setTime(fmt_Exif.parse(date).getTime());
      } catch (java.text.ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

    } catch (IOException e) {
      e.printStackTrace();
    } catch (ParseException e) {
      e.printStackTrace();
    }
    return loc;
  }
 @Override
 protected void onPostExecute(final HttpResponse result) {
   if (dialog.isShowing()) {
     dialog.dismiss();
   }
   if (result != null) {
     int responseCode = result.getStatusLine().getStatusCode();
     String responseBody = "";
     switch (responseCode) {
       case 200:
         HttpEntity entity = result.getEntity();
         if (entity != null) {
           try {
             responseBody = EntityUtils.toString(entity);
           } catch (ParseException e) {
             e.printStackTrace();
           } catch (IOException e) {
             e.printStackTrace();
           }
         }
         break;
     }
     Log.v(TAG, "Response Code => " + responseCode);
     Log.i(TAG, "Response Body => " + responseBody);
   }
 }
  public void loadData(Envelope envelope, int zoom) {

    long timeStart = System.currentTimeMillis();

    // TODO: use fromInternal(Envelope) here
    MapPos minPos = projection.fromInternal(envelope.getMinX(), envelope.getMinY());
    MapPos maxPos = projection.fromInternal(envelope.getMaxX(), envelope.getMaxY());

    String sqlBbox = "" + minPos.x + "," + minPos.y + "," + maxPos.x + "," + maxPos.y;

    // load geometries
    List<Geometry> newVisibleElementsList = new LinkedList<Geometry>();

    try {
      Uri.Builder uri =
          Uri.parse("http://kaart.maakaart.ee/poiexport/roads.php?output=gpoly&").buildUpon();
      uri.appendQueryParameter("bbox", sqlBbox);
      uri.appendQueryParameter("max", String.valueOf(maxObjects));
      Log.debug("Vector API url:" + uri.build().toString());

      JSONObject jsonData = NetUtils.getJSONFromUrl(uri.build().toString());

      if (jsonData == null) {
        Log.debug("No CartoDB data");
        return;
      }

      JSONArray rows = jsonData.getJSONArray("res");

      for (int i = 0; i < rows.length(); i++) {
        JSONObject row = rows.getJSONObject(i);

        String the_geom_encoded = row.getString("g");
        String name = row.getString("n");
        String type = row.getString("t");

        Vector<MapPos> mapPos = GeoUtils.decompress(the_geom_encoded, 5, projection);

        Geometry newObject = new Line(mapPos, new DefaultLabel(name, type), lineStyleSet, null);

        newObject.attachToLayer(this);
        newObject.setActiveStyle(zoom);
        newVisibleElementsList.add(newObject);
      }
    } catch (ParseException e) {
      Log.error("Error parsing data " + e.toString());
    } catch (JSONException e) {
      Log.error("Error parsing JSON data " + e.toString());
    }

    long timeEnd = System.currentTimeMillis();
    Log.debug(
        "OnlineVector loaded N:"
            + newVisibleElementsList.size()
            + " time ms:"
            + (timeEnd - timeStart));
    setVisibleElements(newVisibleElementsList);
  }
 public String get(URI serverPage) {
   try {
     HttpResponse response = this.doGet(serverPage);
     return handleResponse(response);
   } catch (ParseException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   } catch (Exception e) {
     e.printStackTrace();
   }
   return null;
 }
 public String post(URI serverPage, List<BasicNameValuePair> ps) {
   try {
     HttpResponse response = this.doPost(serverPage, ps);
     return handleResponse(response);
   } catch (ParseException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   } catch (Exception e) {
     e.printStackTrace();
   }
   return null;
 }
Beispiel #7
0
  /**
   * 发送微博
   *
   * @param token
   * @param editText
   * @return
   */
  public static Boolean sendWeibo(Oauth2AccessToken token, EditText editText, byte[] imgBuffer) {
    HttpPost postMethod;

    // 组织post参数:此处只实现最简单的发送消息,只填两个参数,其他见http://open.weibo.com/wiki/2/statuses/friends_timeline
    HttpClient httpClient = new DefaultHttpClient();
    List<BasicNameValuePair> params = new LinkedList<BasicNameValuePair>();
    String messageString = editText.getText().toString();
    params.add(new BasicNameValuePair("status", messageString));
    params.add(new BasicNameValuePair("access_token", token.getToken()));
    // 判断是否有图片,选择不同的接口
    if (null != imgBuffer) {
      Log.w(TAG, "Image file include!");
      params.add(new BasicNameValuePair("pic", imgBuffer.toString()));
      postMethod = new HttpPost(Contants.STATUESES_UPDATA_WITH_IMG_URL);
    } else {
      Log.w(TAG, "No images select!");
      postMethod = new HttpPost(Contants.STATUESES_UPDATA_URL);
    }

    try {
      postMethod.setEntity(new UrlEncodedFormEntity(params, "utf-8"));
      HttpResponse httpResponse = httpClient.execute(postMethod);

      // 将返回结果转为字符串,通过文档可知返回结果为json字符串,结构请参考文档
      String resultStr = EntityUtils.toString(httpResponse.getEntity());
      Log.w(TAG, resultStr);

      // 从json字符串中建立JSONObject
      JSONObject resultJson = new JSONObject(resultStr);

      // 如果发送微博失败的话,返回字段中有"error"字段,通过判断是否存在该字段即可知道是否发送成功
      if (resultJson.has("error")) {
        return false;
      } else {
        return true;
      }

    } catch (UnsupportedEncodingException e) {
      Log.w(TAG, e.getLocalizedMessage());
    } catch (ClientProtocolException e) {
      Log.w(TAG, e.getLocalizedMessage());
    } catch (IOException e) {
      Log.w(TAG, e.getLocalizedMessage());
    } catch (ParseException e) {
      Log.w(TAG, e.getLocalizedMessage());
    } catch (JSONException e) {
      Log.w(TAG, e.getLocalizedMessage());
    }

    return false;
  }
Beispiel #8
0
 /**
  * 从格式化时间获取time
  *
  * @param time
  * @param format
  * @return
  */
 public static String formatToTime(String time, String format) {
   Date date = null;
   SimpleDateFormat formatTime = new SimpleDateFormat(format, Locale.CHINA);
   try {
     try {
       date = formatTime.parse(time);
     } catch (java.text.ParseException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   } catch (ParseException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return String.valueOf(date.getTime());
 }
 /** Sets the current URL associated with this load. */
 void setUrl(String url) {
   if (url != null) {
     if (URLUtil.isDataUrl(url)) {
       // Don't strip anchor as that is a valid part of the URL
       mUrl = url;
     } else {
       mUrl = URLUtil.stripAnchor(url);
     }
     mUri = null;
     if (URLUtil.isNetworkUrl(mUrl)) {
       try {
         mUri = new WebAddress(mUrl);
       } catch (ParseException e) {
         e.printStackTrace();
       }
     }
   }
 }
Beispiel #10
0
  private String convert_date(String date) {
    // convert date from text to timestamp using french locale
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMMMMM yyyy", Locale.FRENCH);
    java.util.Date dateObj = null;
    java.sql.Date sqlDate = null;
    try {
      dateObj = simpleDateFormat.parse(date);

      sqlDate = new java.sql.Date(dateObj.getTime());
    } catch (ParseException e) {

      e.printStackTrace();
    } catch (java.text.ParseException e) {

      e.printStackTrace();
    }
    date = sqlDate.toString();
    return date;
  }
Beispiel #11
0
  public static long getCurrentUserId(Oauth2AccessToken token) {
    JSONObject resultJson = null;
    HttpResponse httpResponse;
    HttpClient httpClient = new DefaultHttpClient();

    // 传入get方法的请求地址和参数
    HttpGet getMethod =
        new HttpGet(Contants.GET_CURRENT_USER_INFO_URL + "?" + "access_token=" + token.getToken());
    try {
      // execute返回一个响应对象
      httpResponse = httpClient.execute(getMethod);
      // 响应的内容对象
      // 读取内容,用inputstream读取
      String resultStr = EntityUtils.toString(httpResponse.getEntity());
      resultJson = new JSONObject(resultStr);

      // 如果发送微博失败的话,返回字段中有"error"字段,通过判断是否存在该字段即可知道是否发送成功
      if (resultJson.has("error")) {
        Log.w(TAG, "获取用户信息失败");
      }
      // Log.i(TAG, resultJson.toString());

    } catch (UnsupportedEncodingException e) {
      Log.w(TAG, e.getLocalizedMessage());
    } catch (ClientProtocolException e) {
      Log.w(TAG, e.getLocalizedMessage());
    } catch (IOException e) {
      Log.w(TAG, e.getLocalizedMessage());
    } catch (ParseException e) {
      Log.w(TAG, e.getLocalizedMessage());
    } catch (JSONException e) {
      Log.w(TAG, e.getLocalizedMessage());
    }
    try {
      return resultJson.getLong("uid");
    } catch (JSONException e) {
      e.printStackTrace();
    }
    return 0;
  }
Beispiel #12
0
  /**
   * 使用psot方法发送http请求
   *
   * @param context
   * @param params
   * @param baseUrl
   * @return
   */
  public static JSONObject doPost(
      Context context, List<BasicNameValuePair> params, String baseUrl) {
    JSONObject resultJson = null;
    HttpClient httpClient = new DefaultHttpClient();

    // 传入post方法的请求地址,即发送微博的api接口
    HttpPost postMethod = new HttpPost(baseUrl);
    try {
      postMethod.setEntity(new UrlEncodedFormEntity(params, "utf-8"));
      HttpResponse httpResponse = httpClient.execute(postMethod);

      // 将返回结果转为字符串,通过文档可知返回结果为json字符串,结构请参考文档
      String resultStr = EntityUtils.toString(httpResponse.getEntity());
      Log.w(TAG, resultStr);

      // 从json字符串中建立JSONObject
      resultJson = new JSONObject(resultStr);

      // 如果发送微博失败的话,返回字段中有"error"字段,通过判断是否存在该字段即可知道是否发送成功
      if (resultJson.has("error")) {
        Log.w(TAG, "post success");
      } else {
        Log.w(TAG, "post fali");
      }

    } catch (UnsupportedEncodingException e) {
      Log.w(TAG, e.getLocalizedMessage());
    } catch (ClientProtocolException e) {
      Log.w(TAG, e.getLocalizedMessage());
    } catch (IOException e) {
      Log.w(TAG, e.getLocalizedMessage());
    } catch (ParseException e) {
      Log.w(TAG, e.getLocalizedMessage());
    } catch (JSONException e) {
      Log.w(TAG, e.getLocalizedMessage());
    }
    return resultJson;
  }
Beispiel #13
0
  public String Search_Status(String Word) {
    ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("Lenguaje", Locale.getDefault().getDisplayLanguage()));
    params.add(new BasicNameValuePair("word", Word));

    try {
      JSONArray jArray = HPA.getServerData(params, URL_Search);

      if (jArray != null && jArray.length() > 0) {

        JSONObject json_data = null;

        try {

          int id, year;
          String nombre, autor, instrumento, description, URL, URL_Imagen;
          float precio;
          boolean comprado;

          for (int i = 0; i < jArray.length(); i++) {
            json_data = jArray.getJSONObject(i);
            id = json_data.getInt("Id_S");
            nombre = json_data.getString("Name_Song");
            autor = json_data.getString("Author");
            instrumento = json_data.getString("instrument");
            precio = (float) json_data.getDouble("Price");
            description = json_data.getString("Description");
            year = json_data.getInt("Year");
            comprado = false;
            URL = json_data.getString("URL");
            URL_Imagen = json_data.getString("URL_Image");

            searchinfo.add(
                new PartituraTienda(
                    id,
                    nombre,
                    autor,
                    instrumento,
                    precio,
                    description,
                    year,
                    comprado,
                    URL,
                    URL_Imagen));
          }
        } catch (JSONException e1) {
          Log.d(
              "JSONException SearchAsyncTask",
              "Pues eso, JSONException: " + e1.getMessage() + ", Result: " + jArray.toString());
          this.cancel(true);
        } catch (ParseException e1) {
          Log.d(
              "ParseException SearchAsyncTask",
              "Pues eso, JSONException: " + e1.getMessage() + ", Result: " + jArray.toString());
          this.cancel(true);
        }

      } else {
        Log.e("JSON SearchAsyncTask", "ERROR JArray == " + jArray.toString());
        this.cancel(true);
      }

    } catch (Exception e) {
      this.cancel(true);
      Log.e("Gran Try SearchAsyncTask", e.getMessage());
    }
    return "";
  }
Beispiel #14
0
  /**
   * 获取所有新消息数,UID为当前登陆用户
   *
   * @return
   */
  public static NewMsg getNewMessageCounts(Oauth2AccessToken token, Long currentUID) {
    NewMsg newMsg = new NewMsg();
    JSONObject resultJson = null;
    HttpResponse httpResponse;
    HttpClient httpClient = new DefaultHttpClient();

    // 传入get方法的请求地址和参数
    HttpGet getMethod =
        new HttpGet(
            Contants.GET_MESSAGE_COUNT_URL
                + "?"
                + "access_token="
                + token.getToken()
                + "&true="
                + currentUID);
    try {
      // execute返回一个响应对象
      httpResponse = httpClient.execute(getMethod);
      // 响应的内容对象
      // 读取内容,用inputstream读取
      String resultStr = EntityUtils.toString(httpResponse.getEntity());
      resultJson = new JSONObject(resultStr);
      // 如果发送微博失败的话,返回字段中有"error"字段,通过判断是否存在该字段即可知道是否发送成功
      if (resultJson.has("error")) {
        Log.w(TAG, "获取用户信息失败");
      }
      // Log.i(TAG, resultJson.toString());

    } catch (UnsupportedEncodingException e) {
      Log.w(TAG, e.getLocalizedMessage());
    } catch (ClientProtocolException e) {
      Log.w(TAG, e.getLocalizedMessage());
    } catch (IOException e) {
      Log.w(TAG, e.getLocalizedMessage());
    } catch (ParseException e) {
      Log.w(TAG, e.getLocalizedMessage());
    } catch (JSONException e) {
      Log.w(TAG, e.getLocalizedMessage());
    }

    // 保存消息数
    try {
      newMsg.setStatus(resultJson.getInt("status"));
    } catch (Exception e) {
    }
    try {
      newMsg.setFollower(resultJson.getInt("follower"));
    } catch (Exception e) {
    }
    try {
      newMsg.setCmt(resultJson.getInt("cmt"));
    } catch (Exception e) {
    }
    try {
      newMsg.setDm(resultJson.getInt("dm"));
    } catch (Exception e) {
    }
    try {
      newMsg.setMention(resultJson.getInt("mention_status") + resultJson.getInt("mention_cmt"));
    } catch (Exception e) {
    }

    return newMsg;
  }
  public String execute(String id, String message, boolean paramBoolean) {
    String strEntity =
        "body="
            + message
            + "&tids=id."
            + id
            + /*"&fb_dtsg=" + AppBase.g() +*/ "&__user="******"&__ajax__=true&__metablock__=3";

    httpClient.getParams().setParameter("http.protocol.cookie-policy", "best-match");
    // httpClient.getCookieSpecs().register("lenient", new b(this));

    // HttpClientParams.setCookiePolicy(this.httpClient.getParams(), "lenient");

    httpPost =
        new HttpPost(
            "https://touch.facebook.com/messages/send/?refid=12&m_sess="
                + Session.getActiveSession().getAccessToken());
    httpPost.setHeader(
        "User-Agent", "mozilla/4.0 (mobilephone scp-3200/us/1.0) netfront/3.1 mmp/2.0");
    httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
    httpPost.setHeader("Cookie", f);

    httpResponse = null;

    String[] arrayOfString1;
    int i;
    StringEntity localStringEntity;

    /*if (!this.f.equals(""))
    {
    	this.cookieStore.clear();
    	arrayOfString1 = this.f.split(";");
    	i = 0;
    }

    if (i >= arrayOfString1.length)
    	this.httpContext.setAttribute("http.cookie-store", this.cookieStore);*/

    try {
      localStringEntity = new StringEntity(strEntity, "UTF-8");
      this.httpPost.setEntity(localStringEntity);
    } catch (UnsupportedEncodingException localUnsupportedEncodingException) {
      localUnsupportedEncodingException = localUnsupportedEncodingException;
      System.out.println(
          "HTTPHelp : UnsupportedEncodingException : " + localUnsupportedEncodingException);
      localStringEntity = null;
    }

    try {
      this.httpResponse = this.httpClient.execute(this.httpPost, this.httpContext);
      if (this.httpResponse == null) {
        /*//return "";
        String[] arrayOfString2 = arrayOfString1[i].split("=");
        BasicClientCookie localBasicClientCookie = new BasicClientCookie(arrayOfString2[0], arrayOfString2[1]);
        localBasicClientCookie.setDomain("facebook.com");
        this.cookieStore.addCookie(localBasicClientCookie);*/
        // i++;

      }
    } catch (ClientProtocolException localClientProtocolException) {
      System.out.println(
          "HTTPHelp : ClientProtocolException : " + localClientProtocolException.getMessage());
    } catch (IOException localIOException1) {
      System.out.println("HTTPHelp : IOException : " + localIOException1);

      HttpEntity localHttpEntity = this.httpResponse.getEntity();
      try {
        String str = EntityUtils.toString(localHttpEntity);
        return str;
      } catch (ParseException localParseException) {
        localParseException.printStackTrace();
        return "";
      } catch (IOException localIOException2) {
        localIOException2.printStackTrace();
      }
    }

    return "";
  }
Beispiel #16
0
  public void stateUpdate(ObdCommandJob job) {

    initLocationManager();

    initDbAdapter();

    String cmdName = job.getCommand().getName();
    String cmdResult = job.getCommand().getFormattedResult();

    Log.d(TAG, FuelTrim.LONG_TERM_BANK_1.getBank() + " equals " + cmdName + "?");

    if (AvailableCommandNames.ENGINE_RPM.getValue().equals(cmdName)) {
      //			TextView tvRpm = (TextView) findViewById(R.id.rpm_text);
      //			tvRpm.setText(cmdResult + " rpm");
      rpmMeasurement = Integer.valueOf(cmdResult);
    } else if (AvailableCommandNames.SPEED.getValue().equals(cmdName)) {
      //			TextView tvSpeed = (TextView) findViewById(R.id.spd_text);
      //			tvSpeed.setText(cmdResult + " km/h");
      speed = ((SpeedObdCommand) job.getCommand()).getMetricSpeed();
      speedMeasurement = speed;
      // } else if
      // (AvailableCommandNames.MAF.getValue().equals(cmdName))
      // {
      // maf = ((MassAirFlowObdCommand)
      // job.getCommand()).getMAF();
      // addTableRow(cmdName, cmdResult);
    } else if (FuelTrim.SHORT_TERM_BANK_1.getBank().equals(cmdName)) {
      //			TextView shortTermTrimTextView = (TextView) findViewById(R.id.shortTrimText);
      String shortTermTrim = ((FuelTrimObdCommand) job.getCommand()).getFormattedResult();
      //			shortTermTrimTextView.setText("Short Term Trim: "
      //					+ shortTermTrim + " %");
      try {
        NumberFormat format = NumberFormat.getInstance(Locale.GERMAN);
        Number number;
        number = format.parse(shortTermTrim);
        shortTermTrimBank1Measurement = number.doubleValue();
      } catch (ParseException e) {
        Log.e("obd", "parse exception short term");
        e.printStackTrace();
      } catch (java.text.ParseException e) {
        Log.e("obd", "parse exception short term");
        e.printStackTrace();
      }
      // shortTermTrimBank1Measurement = Double
      // .valueOf(shortTermTrim);
    } else if (FuelTrim.LONG_TERM_BANK_1.getBank().equals(cmdName)) {
      //			TextView longTermTrimTextView = (TextView) findViewById(R.id.longTrimText);
      ltft = ((FuelTrimObdCommand) job.getCommand()).getValue();
      String longTermTrim = ((FuelTrimObdCommand) job.getCommand()).getFormattedResult();
      //			longTermTrimTextView.setText("Long Term Trim: "
      //					+ longTermTrim + " %");

      try {
        NumberFormat format = NumberFormat.getInstance(Locale.GERMAN);
        Number number;
        number = format.parse(longTermTrim);
        longTermTrimBank1Measurement = number.doubleValue();
      } catch (ParseException e) {
        Log.e("obd", "parse exception long term");
        e.printStackTrace();
      } catch (java.text.ParseException e) {
        Log.e("obd", "parse exception long term");
        e.printStackTrace();
      }
      // longTermTrimBank1Measurement =
      // Double.valueOf(longTermTrim);
    } else if (AvailableCommandNames.AIR_INTAKE_TEMP.getValue().equals(cmdName)) {
      //			TextView intakeTempTextView = (TextView) findViewById(R.id.intakeTempText);
      String intakeTemp = ((AirIntakeTemperatureObdCommand) job.getCommand()).getFormattedResult();
      //			intakeTempTextView.setText("Intake Temp: " + intakeTemp
      //					+ " C");
      try {
        intakeTemperatureMeasurement = Integer.valueOf(intakeTemp);
      } catch (NumberFormatException e) {
        Log.e("obd", "intake temp parse exception");
        e.printStackTrace();
      }

      // } else if
      // (AvailableCommandNames.EQUIV_RATIO.getValue().equals(
      // cmdName)) {
      // equivRatio = ((CommandEquivRatioObdCommand) job
      // .getCommand()).getRatio();
      // addTableRow(cmdName, cmdResult);
    } else if (AvailableCommandNames.THROTTLE_POS.getValue().equals(cmdName)) {
      //			TextView throttlePositionTextView = (TextView) findViewById(R.id.throttle);
      String throttlePos = ((ThrottlePositionObdCommand) job.getCommand()).getFormattedResult();
      //			throttlePositionTextView.setText("T. Pos: " + throttlePos);

      try {
        NumberFormat format = NumberFormat.getInstance(Locale.GERMAN);
        Number number;
        number = format.parse(throttlePos);
        throttlePositionMeasurement = number.doubleValue();
      } catch (ParseException e) {
        Log.e("obd", "parse exception throttle");
        e.printStackTrace();
      } catch (java.text.ParseException e) {
        Log.e("obd", "parse exception throttle");
        e.printStackTrace();
      }

      // try {
      // throttlePositionMeasurement = Double
      // .valueOf(throttlePos);
      // Log.e("obd", "cast successful");
      // } catch (NumberFormatException e) {
      // Log.e("obd2", "number format exception");
      // e.printStackTrace();
      // }

    } else if (AvailableCommandNames.FUEL_CONSUMPTION.getValue().equals(cmdName)) {
      //			TextView fuelConsumptionTextView = (TextView) findViewById(R.id.fuelconsumption);
      String fuelCon = ((FuelConsumptionObdCommand) job.getCommand()).getFormattedResult();
      //			fuelConsumptionTextView.setText(fuelCon + " l/h");
      Log.d(TAG, "Fuel consumption");
      Log.d(TAG, fuelCon);

      try {
        NumberFormat format = NumberFormat.getInstance(Locale.GERMAN);
        Number number;
        number = format.parse(fuelCon);
        fuelConsumptionMeasurement = number.doubleValue();
      } catch (ParseException e) {
        Log.e("obd", "parse exception fuelCon");
        e.printStackTrace();
      } catch (java.text.ParseException e) {
        Log.e("obd", "parse exception fuelCon");
        e.printStackTrace();
      }
      // fuelConsumptionMeasurement = Double.valueOf(fuelCon);
      // } else if (AvailableCommandNames.FUEL_ECONOMY.getValue()
      // .equals(cmdName)) {
      // TextView fuelEconomyTextView = (TextView)
      // findViewById(R.id.fueleconomy);
      // String fuelEco = ((FuelEconomyObdCommand)
      // job.getCommand())
      // .getFormattedResult();
      // fuelEconomyTextView.setText(fuelEco + " l/100km");

      // } else if
      // (AvailableCommandNames.FUEL_TYPE.getValue().equals(
      // cmdName)) {
      // TextView fuelTypeTextView = (TextView)
      // findViewById(R.id.fuelTypeTextDisplay);
      // String fuelType = ((FindFuelTypeObdCommand) job
      // .getCommand()).getFormattedResult();
      // try {
      // fuelTypeTextView.setText("Fuel Type: " + fuelType);
      // } catch (Exception e) {
      // Log.e("obd2", "fuel type exception");
      // e.printStackTrace();
      // }
    } else if (AvailableCommandNames.ENGINE_LOAD.getValue().equals(cmdName)) {
      //			TextView engineLoadTextView = (TextView) findViewById(R.id.engineLoadText);
      String engineLoad = ((EngineLoadObdCommand) job.getCommand()).getFormattedResult();
      Log.e("obd2", "Engine Load: " + engineLoad);
      //			engineLoadTextView.setText("Engine load: " + engineLoad);
      try {
        NumberFormat format = NumberFormat.getInstance(Locale.GERMAN);
        Number number;
        number = format.parse(engineLoad);
        engineLoadMeasurement = number.doubleValue();
      } catch (ParseException e) {
        Log.e("obd", "parse exception load");
        e.printStackTrace();
      } catch (java.text.ParseException e) {
        Log.e("obd", "parse exception load");
        e.printStackTrace();
      }
      // engineLoadMeasurement = Double.valueOf(engineLoad);
    } else if (AvailableCommandNames.MAF.getValue().equals(cmdName)) {
      //			TextView mafTextView = (TextView) findViewById(R.id.mafText);
      String maf = ((MassAirFlowObdCommand) job.getCommand()).getFormattedResult();
      //			mafTextView.setText("MAF: " + maf + " g/s");
      try {
        NumberFormat format = NumberFormat.getInstance(Locale.GERMAN);
        Number number;
        number = format.parse(maf);
        mafMeasurement = number.doubleValue();
      } catch (ParseException e) {
        Log.e("obd", "parse exception maf");
        e.printStackTrace();
      } catch (java.text.ParseException e) {
        Log.e("obd", "parse exception maf");
        e.printStackTrace();
      }
      // mafMeasurement = Double.valueOf(maf);
    } else if (AvailableCommandNames.INTAKE_MANIFOLD_PRESSURE.getValue().equals(cmdName)) {
      //			TextView intakePressureTextView = (TextView) findViewById(R.id.intakeText);
      String intakePressure =
          ((IntakeManifoldPressureObdCommand) job.getCommand()).getFormattedResult();
      //			intakePressureTextView.setText("Intake: " + intakePressure
      //					+ "kPa");
      try {
        intakePressureMeasurement = Integer.valueOf(intakePressure);
      } catch (NumberFormatException e) {
        Log.e("obd", "intake pressure parse exception");
        e.printStackTrace();
      }
    } else {
      // addTableRow(cmdName, cmdResult);
    }
    updateMeasurement();
  }
  private ArrayList<Tour> connectGetID() {
    String result = null;
    InputStream is = null;
    StringBuilder sb = null;
    try {
      HttpClient httpclient = new DefaultHttpClient();
      HttpPost httppost = new HttpPost("http://vikabelous.zz.mu/search_hotTours.php");
      HttpResponse response = httpclient.execute(httppost);
      HttpEntity entity = response.getEntity();
      is = entity.getContent();
    } catch (Exception e) {
      Log.e("log_tag", "Error in http connection" + e.toString());
    }
    try {
      BufferedReader reader = new BufferedReader(new InputStreamReader(is), 8);
      sb = new StringBuilder();
      sb.append(reader.readLine() + "\n");
      String line = "0";

      while ((line = reader.readLine()) != null) {
        sb.append(line + "\n");
      }

      is.close();
      result = sb.toString();

    } catch (Exception e) {
      Log.e("log_tag", "Error converting result " + e.toString());
    }

    ArrayList<Tour> TL = new ArrayList<Tour>();

    int id;
    String NameRus;
    String NameEn;
    String TypeEn;
    String TypeRus;
    int Price;
    int days;
    String Transport;
    String photo;
    String Date;

    try {
      JSONArray jArray = new JSONArray(result);
      JSONObject json_data = null;

      for (int i = 0; i < jArray.length(); i++) {
        json_data = jArray.getJSONObject(i);
        id = json_data.getInt("ID");
        NameRus = json_data.getString("TourNameRus");
        NameEn = json_data.getString("TourNameEN");
        TypeEn = json_data.getString("TypeEn");
        TypeRus = json_data.getString("TypeRus");
        Price = json_data.getInt("Price");
        days = json_data.getInt("Days");
        Transport = json_data.getString("Transport");
        photo = json_data.getString("Photo");
        Date = json_data.getString("Date");
        Bitmap B = null;
        try {
          B = BitmapFactory.decodeStream((InputStream) new URL(photo).getContent());
        } catch (MalformedURLException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }

        Tour T = new Tour(id, NameRus, NameEn, TypeEn, TypeRus, Price, days, Transport, B);
        T.Dates.add(Date);
        TL.add(T);
      }

    } catch (JSONException e1) {
      e1.printStackTrace();
    } catch (ParseException e1) {
      e1.printStackTrace();
    }
    return TL;
  }