Page 456 - 2
P. 456
conn.setReadTimeout(3000);
conn.setDoOutput(true);
param = "startX=" + startx + "&startY=" + starty + "&angle=350&speed=60&endX=" + end
x + "&endY=" + endy + "&reqCoordType=WGS84GEO&gpsTime=15000&searchOption=0&resCoordType=WGS84G
EO";
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();
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(getApplicationContext(), Manifest.permission.ACCESS_
FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getAppl
icationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTE
D) {
return null;
}
for (String provider : providers) {
Location l = locationManager.getLastKnownLocation(provider);
if (l == null){
continue;
- 456 -