안드로이드 개발 질문/답변
(글 수 45,052)
GPS 신호가 들어오지 않을 때를 알 수 있는 함수 같은게 있을까요?
아무리 해도 잘 모르겠네요..
2010.02.03 17:07:03
저도 확실하게 살펴본 것이 아니라서 '테스트 및 관련 자료를 찾아보진 않았는데' 를 먼저 적었습니다.
레퍼런스를 보면 리스너에서 이벤트 생기거나, 아니면 처음 시작할 때 부터 getMaxSatellites() 를 사용해서
0이면 gps가 없다고 판단하면 될듯한데, 실제로는 동작하지 않는가보군요
2010.02.04 12:03:33
저도 예전에 이 쪽을 좀 봤었는데...
GPS 신호와 관련된 것은 모두 GpsStatus.Listener에 구현된 메소드에서 처리 가능합니다.
public abstract void onGpsStatusChanged (int event)
Since: API Level 3
Called to report changes in the GPS status. The event number is one of:
When this method is called, the client should callgetGpsStatus(GpsStatus)
to get additional status information.Parameters
event | event number for this notification |
---|
GPS_EVENT_FIRST_FIX 이벤트가 발생하면 일단 GPS위성과 연결은 되었다고 보시면 되고,
이를 이용하여 LocationManager 등을 통해 위치를 받기 위해서는 잠시 더 기다려야 합니다.
GPS를 사용하여 현재 위치를 받았을 경우, 위치 파악에 사용된 GPS위성의 수는 LocationListener의
public abstract void onStatusChanged (String provider, int status, Bundle extras)
Since: API Level 1
Called when the provider status changes. This method is called when a provider is unable to fetch a location or if the provider has recently become available after a period of unavailability.
Parameters
provider | the name of the location provider associated with this update. |
---|---|
status | OUT_OF_SERVICE if the provider is out of service, and this is not expected to change in the near future; TEMPORARILY_UNAVAILABLE if the provider is temporarily unavailable but is expected to be available shortly; and AVAILABLE if the provider is currently available. |
extras | an optional Bundle which will contain provider specific status variables. A number of common key/value pairs for the extras Bundle are listed below. Providers that use any of the keys on this list must provide the corresponding value as described below.
|
를 이용하시면 됩니다. 위성의 개수를 satellites라는 Extra 데이터로 받게 되어있죠.
이것을 사용해보면 되지 않을까요?
http://developer.android.com/reference/android/location/GpsStatus.Listener.html