마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

현재 측정되는 GPS 위성 개수를 출력할 수 있는 방법이 있을까요??

0 추천

안녕하세요

제가 원하는 것은 현재 측정되는 GPS의 위성 개수를 출력하고자 하는것입니다.

측정되는 위성 종류가 In view(관측되는 위성), In use(실제 거리계산 가능한 위성) 으로 나뉜다고 알 고 있습니다.

아무튼 , 구글 검색 결과

private boolean isGPSEnabled = false;

private boolean registGps = false;

 

@Override

public void onGpsStatusChanged(int event) {

    GpsStatus status = locationManager.getGpsStatus(null);

 

    Iterable sats = status.getSatellites();

    Iterator satI = sats.iterator();

    int count = 0;

 

    while (satI.hasNext()) {

        GpsSatellite gpssatellite = (GpsSatellite) satI.next();

        if (gpssatellite.usedInFix()) {

            count++;

        }

    }

    if (count > 3) {

    isGPSEnabled = true;

        if (!registGps) {

            locationManager.removeUpdates(this);

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,2000, 0, this);

            registGps = true;

            CommFun.ToastMsgDebug(this,

            "현재 GPS 위성 갯수 : provider=gps," + count);

            }

    } else {

        isGPSEnabled = false;

        }    

    }

[출처 : http://bbunge.tistory.com/154]

위와 같은 방법을 알게 되었는데요..

문제는 import android.location.GpsStatus; 를 하면

The type GpsStatus is deprecated라고 사용할 수 없다고 까만줄이 딱 그어 집니다...ㅠㅠ

GpsStatus는 더 이상 사용할 수 없는 class 인가요??

개발 환경은 안드로이드 5.0.1 이고 이클립스를 사용해서 코딩했습니다.

혹시 다른 방법이나 해결책 좀 알려주시면 대단히 감사하겠습니다. ㅠㅠ

 

기무치찌개 (200 포인트) 님이 2016년 10월 6일 질문

1개의 답변

0 추천
23 버전 까지는 저거 쓰시고 24버전 부터는 OnNmeaMessageListener 를 쓰세요

https://developer.android.com/sdk/api_diff/24/changes/android.location.LocationManager.html

전달되는 데이터는 어차피 NMEA 데이터라 동일할 터이고 파싱도 동일하게 쓰이겠네요
aucd29 (218,390 포인트) 님이 2016년 10월 7일 답변
...