<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      高德地圖應用——與云圖后臺交互

      用途:

      在高德地圖中查看已存在的興趣點信息,并上報GPS位置錯誤。

      準備工作:
      是在高德申請開發賬號,建立一個云圖。(過程略。)
      _name字段作為唯一標示。
      云圖的表增加一個字段reportid,用以辨別是哪個終端上報的位置信息,防止重復上報。


      主要代碼:
      1.開啟GPS定位:

      private void initgps() {
      myLocation.setText("開始定位...");
      locationManager = LocationManagerProxy.getInstance(PoiActivity.this);
      // API定位采用GPS定位方式,第一個參數是定位provider,第二個參數時間最短是2000毫秒,第三個參數距離間隔單位是米,第四個參數是定位監聽者
      // locationManager.requestLocationUpdates(
      // LocationManagerProxy.GPS_PROVIDER, 2000, 10, this);
      locationManager.requestLocationData(LocationManagerProxy.GPS_PROVIDER,
      2000, 10, this);
      }

       

      2.關閉GPS定位:

      private void stopgps() {
      myLocation.setText("定位停止");
      locationisok = false;
      if (locationManager != null) {
      locationManager.removeUpdates(this);
      }
      locationManager = null;
      }

       

      3.獲取當前GPS信息

      /**
      * gps定位回調方法
      */
      @Override
      public void onLocationChanged(AMapLocation location) {
      if (location != null) {
      Double geoLat = location.getLatitude();
      Double geoLng = location.getLongitude();
      this.lat = geoLat;
      this.lng = geoLng;
      
      
      String str = ("定位成功:(" + geoLng + "," + geoLat + ")"
      + "\n精 度 :" + location.getAccuracy() + "米"
      + "\n定位方式:" + location.getProvider() + "\n定位時間:" + AMapUtil
      .convertToTime(location.getTime()));
      myLocation.setText(str);
      thisplocation = geoLng + "," + geoLat;
      locationisok = true;
      } else {
      locationisok = false;
      }
      }

       

      4.獲取手機串號作為reportid

      private String getimei() {
      String is = null;
      try {
      TelephonyManager telephonyManager = (TelephonyManager) cx
      .getSystemService(Context.TELEPHONY_SERVICE);
      is = telephonyManager.getDeviceId();
      } catch (Exception e) {
      is = "";
      }
      return is;
      }

       

      5.查詢是否重復HttpGet方法

      public int checkexist(String sname, String srid) {
      // String sname 興趣點名稱, String srid 電話IMEI
      String BASEURL = "http://yuntuapi.amap.com/datamanage/data/list?key=你的KEY"
      + "limit=10&page=1&filter=";
      String LASTURL = "&tableid=你的tableid";
      String asks = "";
      // 檢查IMEI是否為空
      srid.replaceAll(" ", "");
      if (srid == null || srid.length() <= 0) {
      asks = "_name:" + sname;
      } else {
      asks = "_name:" + sname + "+reportid:" + srid;
      }
      ;
      
      String countid = "10";// 未成功獲取信息,返回>1的數值供判斷。
      try {
      // 創建一個HttpClient對象
      HttpClient httpclient = new DefaultHttpClient();
      HttpGet request = new HttpGet(BASEURL + asks + LASTURL);
      request.addHeader("Accept", "text/json");
      // JSON的解析過程
      HttpResponse response = httpclient.execute(request);
      // 獲取HttpEntity
      HttpEntity entity = response.getEntity();
      int code = response.getStatusLine().getStatusCode();
      if (code == 200) {
      // 獲取響應的結果信息
      String json = EntityUtils.toString(entity, "UTF-8");
      // JSON的解析過程
      if (json != null) {
      JSONObject jsonObject = new JSONObject(json);
      countid = jsonObject.get("count").toString();
      testcount = countid;
      testinfo = jsonObject.get("info").toString();
      }
      }
      
      } catch (ClientProtocolException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      }
      return Integer.valueOf(countid).intValue();
      }
      
      
      

       

      6.上報GPS位置信息HttpPost方法
      private boolean postreport(String sname, String sid, String slocation) {
      String BASEURL = "http://yuntuapi.amap.com/datamanage/data/create?";
      String KEYS = "你的KEY";
      String TID = "你的tableid";
      
      try {
      HttpClient httpclient = new DefaultHttpClient();
      String uri = BASEURL;//
      HttpPost httppost = new HttpPost(uri);
      httppost.addHeader("Content-Type",
      "application/x-www-form-urluncoded");
      
      JSONObject obj = new JSONObject();
      obj.put("_name", sname);
      obj.put("_location", slocation);
      obj.put("reportid", sid);
      
      List<NameValuePair> formparams = new ArrayList<NameValuePair>();
      formparams.add(new BasicNameValuePair("key", KEYS));
      formparams.add(new BasicNameValuePair("tableid", TID));
      formparams.add(new BasicNameValuePair("data", obj.toString()));
      UrlEncodedFormEntity uefEntity;
      
      uefEntity = new UrlEncodedFormEntity(formparams, "UTF-8");
      httppost.setEntity(uefEntity);
      
      HttpResponse response;
      response = httpclient.execute(httppost);
      // 檢驗狀態碼,如果成功接收數據
      int code = response.getStatusLine().getStatusCode();
      if (code == 200) {
      String rev = EntityUtils.toString(response.getEntity());// 返回json格式:
      obj = new JSONObject(rev);
      String infos = obj.getString("info");
      String stats = obj.getString("status");
      if (infos.equals("OK")) {
      return true;
      }
      }
      } catch (ClientProtocolException e) {
      } catch (IOException e) {
      } catch (Exception e) {
      }
      return false;
      }

       

       


      7.更新界面線程

      private class Asynpost extends AsyncTask<Void, Void, String> {
      private final String TAG = "dopost";
      
      // onPreExecute方法在execute()后執行
      @Override
      protected void onPreExecute() {
      Log.i(TAG, "onPreExecute() enter");
      postisok = false;
      }
      
      // onCancelled方法用于取消Task執行,更新UI
      @Override
      protected void onCancelled() {
      Log.i(TAG, "onCancelled() called");
      postisok = false;
      }
      
      @Override
      protected void onPostExecute(String result) {
      // mPoiTextView.setText(result);
      dissmissProgressDialog();
      if (result.equals("true")) {
      Toast.makeText(cx, "您的信息已成功提交", Toast.LENGTH_LONG)
      .show();
      }else if (result.equals("false")) {
      Toast.makeText(cx, "您的信息提交失敗,原因是:您已經提交過信息。",
      Toast.LENGTH_LONG).show();
      }else if (result.equals("error")){
      Toast.makeText(cx, "您的信息提交失敗,原因是:可能是網絡問題,",
      Toast.LENGTH_LONG).show();
      };
      }
      
      @Override
      protected String doInBackground(Void... arg0) {
      // TODO Auto-generated method stub
      String rr = "";
      if (checkexist(thispname, repid) == 0) {
      if (postreport(thispname, repid, thisplocation)){
      postisok = true;
      rr = "true";    
      }else{
      postisok = false;
      rr = "error";    
      };
      
      } else {
      postisok = false;
      rr = "false";
      }
      return rr;
      }
      
      }

       

      posted @ 2015-03-02 10:05  happyhills  閱讀(1759)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 天堂V亚洲国产V第一次| 无码三级av电影在线观看| 熟女视频一区二区三区嫩草| 亚洲qingse中文字幕久久| 在线日韩日本国产亚洲| 国产成人高清亚洲一区二区| 日本边添边摸边做边爱喷水| 欧美性受xxxx白人性爽| 最新亚洲av日韩av二区| 日本九州不卡久久精品一区| 亚洲av无码成人影院一区| 中文字幕乱码一区二区免费| 亚洲精品日本久久久中文字幕| 亚洲欧美综合中文| 国产69久久精品成人看| 国产涩涩视频在线观看| 在线 欧美 中文 亚洲 精品| 国产成人精品午夜2022| 亚洲一区二区无码影院| 国产亚洲色视频在线| 天天躁久久躁日日躁| 97碰碰碰免费公开在线视频| 亚洲精品麻豆一区二区| 武城县| 少妇人妻偷人精品无码视频新浪| 强开少妇嫩苞又嫩又紧九色| 欧美人与禽2o2o性论交| 精品午夜福利短视频一区| 国产亚洲999精品AA片在线爽| 国产一区二区三区av在线无码观看| 亚洲国产成人久久综合人| 色伦专区97中文字幕| 久久99精品久久久久久青青| 精品久久一线二线三线区| 亚洲精品无码成人aaa片| 99久久精品国产熟女拳交| 无码熟妇人妻AV影音先锋| 国产成人高清亚洲综合| 99九九热久久只有精品| 亚洲三级香港三级久久| 久久久精品2019中文字幕之3|