2014-10-24 3 views
0

위도와 경도를 전달하여 위치 주소를 얻으려고합니다. 그러나 주소는 항상 null입니다. 안드로이드의 Geocoder 문서에서Google 유리 - 위치에서 주소를 가져올 수 없습니다.

다음

내 코드는 ...

@Override 
     public void onLocationChanged(Location location) { 
     // Called when a new location is found by the network location provider. 
     if (location != null){ 
     Geocoder geocoder = new Geocoder(Start_service.this.getBaseContext(), Locale.getDefault()); 
     // lat,lng, your current location 

     try { 
      lati= location.getLatitude(); 
      longi=location.getLongitude(); 
      speed=location.getSpeed(); 
      addresses =geocoder.getFromLocation(location.getLatitude(),location.getLongitude(), 1); 
     System.out.println("Address is"+ addresses); 
     } 
     catch (IOException e) { 
     System.out.println(e); 
     e.printStackTrace(); 
     } 

답변

1

:

Geocoder 클래스는 핵심 안드로이드 프레임 워크에 포함되지 않은 백엔드 서비스를 필요로한다. Geocoder 쿼리 메서드는 플랫폼에 백엔드 서비스가 없으면 빈 목록을 반환합니다. Geocoder 구현이 있는지 확인하려면 isPresent() 메서드를 사용하십시오.

Glass에서 지원 받고 싶다면 issues tracker에 기능 요청을 제출하십시오.

Google Geocoding API과 같은 대체 API를 사용할 수도 있습니다.

+0

GPS를 휴대 전화에 연결하면 작동합니다. Wi-Fi로 작동하지 않습니다. –

관련 문제