2013-12-13 3 views
0

Google Play 서비스를 사용하여 가장 정확한 현재 좌표를 얻는 데 가장 좋은 방법이 무엇인지 궁금합니다.가장 정확한 전류 좌표 받기

public class MainActivity extends FragmentActivity implements 
     GooglePlayServicesClient.ConnectionCallbacks, 
     GooglePlayServicesClient.OnConnectionFailedListener { 
    ... 
    // Global variable to hold the current location 
    Location mCurrentLocation; 
    ... 
    mCurrentLocation = mLocationClient.getLastLocation(); 
    ... 
} 

또는과 같이, 업데이트 콜백을 사용 : 그것은과 같이, getLastLocation()을 사용하는 것입니다

public class MainActivity extends FragmentActivity implements 
     GooglePlayServicesClient.ConnectionCallbacks, 
     GooglePlayServicesClient.OnConnectionFailedListener, 
     LocationListener { 
    ... 
    // Define the callback method that receives location updates 
    @Override 
    public void onLocationChanged(Location location) { 
     // Report to the UI that the location was updated 
     String msg = "Updated Location: " + 
       Double.toString(location.getLatitude()) + "," + 
       Double.toString(location.getLongitude()); 
     Toast.makeText(this, msg, Toast.LENGTH_SHORT).show(); 
    } 
    ... 
} 

어떤 생각?

+0

이다, 모두 당신에게 위치를 반환하는 수익을 창출 GPS가 첫 번째 수정을 얻 자마자 콜백을 제공합니다 : http://stackoverflow.com/questions/19365035/location-servise-gps-force-closed/19366773#19366773 도움을 주시면 upvote주세요 – cYrixmorten

+0

소요 시간 수집 할 좌표가 내게 큰 우선 순위이므로, 얼마나 많은 양을 사용할 수 있는지 확신 할 수 없습니다. –

+0

좋아,하지만 당신이 이미 시동기에서했던 것처럼 융합 된 위치를 사용하는 것을 방해하지 않으며, 첫 번째 수정이 이루어 지자 마자 GPS로 바꾼다. – cYrixmorten

답변

1

getLastLocation()은 현재 위치로 보장되지는 심지어 당신이 당신의 가장 정확한 현재 위치에 관심이 있다면 다음 위치 업데이트를 요청하는 것이 가장 좋은 건 내가 클래스를 생성 한