location = locManager.getLastKnownLocation(provider);
// TODO Auto-generated method stub
String mLatLonString;
latText = (TextView) findViewById(R.id.tvLatitude);
lngText = (TextView) findViewById(R.id.tvLongitude);
if(location != null) {
double latPoint = location.getLatitude();
double lngPoint = location.getLongitude();
latText.setText(String.valueOf(latPoint));
lngText.setText(String.valueOf(lngPoint))
mLatLonString = "Can't find your location";
latText.setText("Location : " + mLatLonString);
lngText.setText("Location : " + mLatLonString);
}
아래 내용에서 찾으시면 대강 나올 것 같습니다. requestLocationUpdates 에 대한 설명을 구글 번역기로 한 줄 씩 번역을 해 보았습니다.
void android.location.LocationManager.requestLocationUpdates(String provider, long minTime, float minDistance, LocationListener listener)
public void requestLocationUpdates (String provider, long minTime, float minDistance, LocationListener listener)
Since: API Level 1
Registers the current activity to be notified periodically by the named provider. Periodically, the supplied LocationListener will be called with the current Location or with status updates.
이름이 공급자가 주기적으로 알림을 현재의 활동을 등록합니다. 정기적으로 공급 LocationListener은 현재 위치 또는 상태 업데이트와 함께 호출됩니다.
It may take a while to receive the first location update. If an immediate location is required, applications may use the getLastKnownLocation(String) method.
처음 위치 업데이트를받을 시간이 걸릴 수 있습니다.즉시 위치가 필요한 경우, 응용 프로그램은 getLastKnownLocation (문자열) 메소드를 사용할 수 있습니다.
In case the provider is disabled by the user, updates will stop, and the onProviderDisabled(String) method will be called. As soon as the provider is enabled again, the onProviderEnabled(String) method will be called and location updates will start again.
공급자가 사용자에 의해 비활성화되어 경우, 업데이트는 중단되며, onProviderDisabled (문자열) 메서드가 호출 될 것입니다.공급자가 다시 활성화되는 즉시, onProviderEnabled (문자열) 메서드가 호출 될 것입니다 및 위치 업데이트가 다시 시작됩니다.
The update interval can be controlled using the minTime parameter. The elapsed time between location updates will never be less than minTime, although it can be more depending on the Location Provider implementation and the update interval requested by other applications.
업데이트 간격은 minTime 매개 변수를 사용하여 제어 할 수 있습니다. 더 위치 공급자 구현과 다른 응용 프로그램에 의해 요청 된 업데이트 간격에 따라 할 수 있지만 위치 업데이트 사이의 경과 시간은 minTime 미만이어야하지 않습니다.
Choosing a sensible value for minTime is important to conserve battery life. Each location update requires power from GPS, WIFI, Cell and other radios. Select a minTime value as high as possible while still providing a reasonable user experience. If your application is not in the foreground and showing location to the user then your application should avoid using an active provider (such as NETWORK_PROVIDER or GPS_PROVIDER), but if you insist then select a minTime of 5 * 60 * 1000 (5 minutes) or greater. If your application is in the foreground and showing location to the user then it is appropriate to select a faster update interval.
minTime에 대한 합리적인 가치를 선택하면 배터리 수명을 절약하는 것이 중요합니다. 각 위치 업데이트는 GPS, WIFI, 세포 및 다른 라디오의 전원이 필요합니다. 아직 적절한 사용자 경험을 제공하는 동시에 가능한 한 높은 minTime 값을 선택합니다. 응용 프로그램이 전경 및 사용자에게 위치를 표시하지 않을 경우 사용자 응용 프로그램이 활성화 된 공급자를 (예 : NETWORK_PROVIDER 또는 GPS_PROVIDER 등)를 사용하지 않아야하지만, 당신의 원한다면 다음 5 minTime을 선택 * 60 * 1000 (5 분) 또는 더. 응용 프로그램이 전경 및 사용자에게 위치를 보여주는에 있다면 그것은 빠르고 업데이트 간격을 선택 적합합니다.
The minDistance parameter can also be used to control the frequency of location updates. If it is greater than 0 then the location provider will only send your application an update when the location has changed by at least minDistance meters, AND at least minTime milliseconds have passed. However it is more difficult for location providers to save power using the minDistance parameter, so minTime should be the primary tool to conserving battery life.
minDistance 매개 변수는 위치 업데이트 빈도를 제어하는 데 사용할 수 있습니다. 가 0보다 크면 다음 위치 제공 업체는 위치가 이상 minDistance 미터에 의해 변경되었습니다 업데이트는 응용 프로그램을 보내드립니다, 적어도 minTime 밀리 초는 지났습니다. 그러나이 minDistance 매개 변수를 사용하여 전원을 절약하기 위해 위치 공급자를 위해 더 어렵습니다, ??그래서 minTime는 보존 배터리 수명에 주요 도구가 될 것입니다.
If your application wants to passively observe location updates triggered by other applications, but not consume any additional power otherwise, then use the PASSIVE_PROVIDER This provider does not actively turn on or modify active location providers, so you do not need to be as careful about minTime and minDistance. However if your application performs heavy work on a location update (such as network activity) then you should select non-zero values for minTime and/or minDistance to rate-limit your update frequency in the case another application enables a location provider with extremely fast updates.
응용 프로그램이 수동적으로 다른 응용 프로그램에 의해 트리거 위치 업데이트를 관찰하기를 원하지만 그렇지 않으면 추가 전원을 소비하지 않을 경우, 다음이 제공 업체가 적극적으로 활성화 된 위치 공급자를 켜거나 수정하지 않는 PASSIVE_PROVIDER을 사용하므로 minTime에 대해서주의 할 필요가 없습니다 그리고 minDistance. 응용 프로그램이 위치 업데이트 (예 : 네트워크 활동 등)에서 많은 작업을 수행하는 경우에는 다음 다른 응용 프로그램이 매우 빠르게과 위치 제공을 가능하게하는 경우에 업데이트 빈도를 속도 - 제한하기 minTime 및 / 또는 minDistance이 아닌 제로 값을 선택해야합니다 업데이트합니다.
The calling thread must be a Looper thread such as the main thread of the calling Activity.
전화 스레드는 호출 활동의 주 스레드로 자벌레 스레드 수 있어야합니다.
Prior to Jellybean, the minTime parameter was only a hint, and some location provider implementations ignored it. From Jellybean and onwards it is mandatory for Android compatible devices to observe both the minTime and minDistance parameters.
젤리 빈에 앞서, minTime 매개 변수는 힌트이었고, 일부 위치 제공 업체 구현은 무시. 젤리 빈과 이후는 minTime와 minDistance 매개 변수를 모두 관찰 할 안드로이드 호환 장치에 필수입니다.
Parameters
provider the name of the provider with which to register
등록되는 공급자의 공급자의 이름
minTime minimum time interval between location updates, in milliseconds
(밀리 초) 위치 업데이트 사이 minTime 최소 시간 간격,
minDistance minimum distance between location updates, in meters
m의 위치 업데이트 사이의 minDistance 최소 거리,
listener a {#link LocationListener} whose onLocationChanged(Location) method will be called for each location update
그의 onLocationChanged (위치) 메서드를 리스너 {# 링크 LocationListener}은 각 위치 업데이트 호출됩니다
Throws
IllegalArgumentException if provider is null or doesn't exist on this device
IllegalArgumentException if listener is null
RuntimeException if the calling thread has no Looper
SecurityException if no suitable permission is present for the provider.
리스너를 등록 했으면 위치가 바뀌면 onLocationChanged가 호출 됩니다. requestLocationUpdates뒤에 정확히 어딘지는 기억이
안나지만 Property중에 onLocationChanged가 호출되는 주기가 m단위로 값을 넣는 부분이 있습니다.
혹여 그렇지는 않으시겠지만, GPS라는게 실내에서는 잡히지 않습니다.
그리고 만약 에뮬에서 돌리시는거라면, DDMS에 GPS값을 던져주는 기능이 있으니 확인해 보세요.