아래와 같이 하여 현재 위치를 구해오려고 합니다.
그런데 아무리 해봐도 위도,경도 모두 0 만 나오는데
이유가 무엇인가요ㅠ
쥐피에스 다 켜있고 한데 왜 자꾸 0 만 나오는지 모르겠습니다.
조언 부탁드립니다.
// LocationListener의 핸들을 얻음
locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
// GPS로 부터 위치정보를 업데이트 요청, 1초마다 5km 이동시
locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 5, this);
// 기지국으로 부터 위치정보를 업데이트 요청
//locManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 5, this);
// 주소를 확인하기 위한 Geocoder KOREA 와 KOREAN 둘다 가능
geoCoder = new Geocoder(this, Locale.KOREAN);
GetLocations();
public void GetLocations() {
// 텍스트뷰를 찾음
TextView latText = (TextView) findViewById(R.id.tvLatitude);
TextView lngText = (TextView) findViewById(R.id.tvLongitude);
TextView speedText = (TextView) findViewById(R.id.tvSpeed);
TextView jusoText = (TextView) findViewById(R.id.tvAddress);
StringBuffer juso = new StringBuffer();
if (myLocation != null) {
latPoint = myLocation.getLatitude();
lngPoint = myLocation.getLongitude();
speed = (float)(myLocation.getSpeed() * 3.6);
try {
// 위도,경도를 이용하여 현재 위치의 주소를 가져온다.
List<Address> addresses;
addresses = geoCoder.getFromLocation(latPoint, lngPoint, 1);
for(Address addr: addresses){
int index = addr.getMaxAddressLineIndex();
for(int i=0;i<=index;i++){
juso.append(addr.getAddressLine(i));
juso.append(" ");
}
juso.append("\n");
}
} catch (IOException e) {
e.printStackTrace();
}
}
latText.setText(String.valueOf(latPoint));
lngText.setText(String.valueOf(lngPoint));
speedText.setText(String.valueOf(speed));
jusoText.setText(String.valueOf(juso));
}
public void onLocationChanged(Location location) {
Log.d("location", "location changed");
myLocation = location;
}
public void onProviderDisabled(String s) {
}
public void onProviderEnabled(String s) {
}
public void onStatusChanged(String s, int i, Bundle bundle) {
}