Page 467 - 2
P. 467
param = "startX=" + startx + "&startY=" + starty + "&angle=350&speed=60& endPoiId=" +
endpoiid + "&endRpFlag=" + endrpflag + "&endX=" + endx + "&endY=" + endy + "&reqCoordType=WGS84GEO
&gpsTime=15000&endName=" + endname + "&searchOption=0&resCoordType=WGS84GEO";
OutputStream outputStream = conn.getOutputStream();
outputStream.write(param.getBytes());
outputStream.flush();
outputStream.close();
// 응답 내용(BODY) 구하기
int requestCode = conn.getResponseCode();
if (requestCode == HttpURLConnection.HTTP_OK) {
inputStream = conn.getInputStream();
baos = new ByteArrayOutputStream();
byte[] bytebuffer = new byte[1024];
byte[] bytedata = null;
int length = 0;
while ((length = inputStream.read(bytebuffer, 0, bytebuffer.length)) != -1) {
baos.write(bytebuffer, 0, length);
}
bytedata = baos.toByteArray();
Log.d("BluetoothManager", E_POI.getPOIName());
result = new String(bytedata);
Log.d("BluetoothManager", result);
}
conn.disconnect();
} catch (Exception e) {
Log.d("BluetoothManager", e.toString());
}
return result;
}
public Location getLastKnownLocation() {
List<String> providers = locationManager.getProviders(true);
Location location = null;
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATIO
N) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(context, Manifest.per
mission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return null;
}
for (String provider : providers) {
Location l = locationManager.getLastKnownLocation(provider);
if (l == null){
continue;
}
if(location == null || l.getAccuracy() < location.getAccuracy()){
location = l;
}
- 467 -