Created
June 16, 2012 06:23
-
-
Save laabroo/2940184 to your computer and use it in GitHub Desktop.
GetData From Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String loadData(double lat, double lon, double rad) { | |
httpGet = new HttpGet("http://laabroo.cu.cc/lokasi.php?lat=" + lat | |
+ "&lon=" + lon + "&rad=" + rad); | |
StringBuilder builder = new StringBuilder(); | |
httpClient = new DefaultHttpClient(); | |
try { | |
response = httpClient.execute(httpGet); | |
StatusLine statusLine = response.getStatusLine(); | |
int statuscode = statusLine.getStatusCode(); | |
if (statuscode == 200) { | |
HttpEntity entity = response.getEntity(); | |
InputStream content = entity.getContent(); | |
BufferedReader reader = new BufferedReader( | |
new InputStreamReader(content)); | |
String line; | |
while ((line = reader.readLine()) != null) { | |
builder.append(line); | |
Log.i("Data : ", line); | |
} | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
return builder.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ini adalah cara bagaimana mengambil data dari server dengan mengirimkan parameter Latitude, Longitude, Radius. Dan di kembalikan lagi menjadi sebuah object String.