2012-04-28 20 views
-1

受信したLat-Longをサーバーに送信してデータベースに保存する必要があるLat-Longアプリケーションを作成しました。 lat-longをサーバーに送信する方法を教えてください。LatLongをサーバーに送信

答えて

0

MySQLを使用している場合は、パラメータとして緯度と長い受け取るPHPスクリプトを使用して、クエリにそれらを解析することができます。..

ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); 
nameValuePairs.add(new BasicNameValuePair("lat", lat)); 
nameValuePairs.add(new BasicNameValuePair("lng", lng)); 

try { 
      HttpClient httpClient = new DefaultHttpClient(); 
      HttpPost httpPost = new HttpPost("http://yourserver.com/script.php"); 
      httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); 
      HttpResponse response = httpClient.execute(httpPost); 
      HttpEntity entity = response.getEntity(); 
      is = entity.getContent();    
     }catch (Exception e) { 
      // TODO: handle exception 
      Log.e("log_tag", e.toString()); 
      return false; 
      //Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show(); 
     } 
関連する問題