本文整理匯總了Java中android.location.GpsSatellite.usedInFix方法的典型用法代碼示例。如果您正苦於以下問題:Java GpsSatellite.usedInFix方法的具體用法?Java GpsSatellite.usedInFix怎麽用?Java GpsSatellite.usedInFix使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.location.GpsSatellite
的用法示例。
在下文中一共展示了GpsSatellite.usedInFix方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convertNmeaGSA
import android.location.GpsSatellite; //導入方法依賴的package包/類
public static String convertNmeaGSA(List<GpsSatellite> satellites) {
StringBuilder localStringBuilder = new StringBuilder();
localStringBuilder.append("$GPGSA,,,");
int satelliteChannelCount = 12;
for (GpsSatellite s : satellites) {
if ((s.getPrn() > 0) && s.usedInFix()) {
localStringBuilder.append(String.format(Locale.getDefault(), "%02d,", s.getPrn()));
satelliteChannelCount--;
}
if (satelliteChannelCount == 0) {
break;
}
}
while (satelliteChannelCount-- > 0) {
localStringBuilder.append(",");
}
localStringBuilder.append(",,,4");
localStringBuilder.append(calcNmeaCrc(localStringBuilder));
return localStringBuilder.toString();
}
示例2: onGpsStatusChanged
import android.location.GpsSatellite; //導入方法依賴的package包/類
@Override public void onGpsStatusChanged(int event) {
gpsStatus = locationManager.getGpsStatus(gpsStatus);
switch (event) {
case GpsStatus.GPS_EVENT_STARTED:
case GpsStatus.GPS_EVENT_FIRST_FIX:
case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
case GpsStatus.GPS_EVENT_STOPPED:
default:
}
int count_seen = 0;
int count_fix = 0;
for (GpsSatellite s: gpsStatus.getSatellites()) {
count_seen++;
if (s.usedInFix())
count_fix++;
// Log.d(TAG, "getSnr=" + s.getSnr());
}
// Log.d(TAG, "LocusService.onGpsStatusChanged event=" + event
// + ", satellites=" + count_fix + "/" + count_seen + "/" + gpsStatus.getMaxSatellites()
// + ", timeToFirstFix=" + gpsStatus.getTimeToFirstFix()
// );
}
示例3: onLocationChanged
import android.location.GpsSatellite; //導入方法依賴的package包/類
@Override
public void onLocationChanged(Location location) {
if (MAP_MODE == FEATURE_DRAW_LINE_GPS_MODE || MAP_MODE == FEATURE_DRAW_POLYGON_GPS_MODE
|| MAP_MODE == FEATURE_DRAW_POINT_GPS_MODE) {
int satellitesInFix = 0;
for (GpsSatellite sat : locationManager.getGpsStatus(null).getSatellites()) {
if (sat.usedInFix()) {
satellitesInFix++;
}
}
if (actionMode != null) {
int accuracy = (int) locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER).getAccuracy();
actionMode.setTitle(accuracy + getResources().getString(R.string.gps_accuracy));
actionMode.setSubtitle(satellitesInFix + " " + getResources().getString(R.string.sats_use_msg));
}
}
}
示例4: updateSats
import android.location.GpsSatellite; //導入方法依賴的package包/類
public void updateSats() {
if ((mlocManager != null) && (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED))
{
final GpsStatus gs = mlocManager.getGpsStatus(null);
int sats_inview = 0; // Satellites in view;
int sats_used = 0; // Satellites used in fix;
if (gs != null) {
Iterable<GpsSatellite> sats = gs.getSatellites();
for (GpsSatellite sat : sats) {
sats_inview++;
if (sat.usedInFix()) sats_used++;
//Log.w("myApp", "[#] GPSApplication.java - updateSats: i=" + i);
}
_NumberOfSatellites = sats_inview;
_NumberOfSatellitesUsedInFix = sats_used;
} else {
_NumberOfSatellites = NOT_AVAILABLE;
_NumberOfSatellitesUsedInFix = NOT_AVAILABLE;
}
} else {
_NumberOfSatellites = NOT_AVAILABLE;
_NumberOfSatellitesUsedInFix = NOT_AVAILABLE;
}
//Log.w("myApp", "[#] GPSApplication.java - updateSats: Total=" + _NumberOfSatellites + " Used=" + _NumberOfSatellitesUsedInFix);
}
示例5: onGpsStatusChanged
import android.location.GpsSatellite; //導入方法依賴的package包/類
@Override
public void onGpsStatusChanged(int event)
{
switch (event) {
case GpsStatus.GPS_EVENT_STARTED:
case GpsStatus.GPS_EVENT_STOPPED:
mHasGPSFix = false;
break;
case GpsStatus.GPS_EVENT_FIRST_FIX:
mHasGPSFix = true;
break;
case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
mSatellitesCount = 0;
for (GpsSatellite sat : mLocationManager.getGpsStatus(null).getSatellites()) {
if (sat.usedInFix()) {
mSatellitesCount++;
}
}
break;
}
}
示例6: formatGpsGsa
import android.location.GpsSatellite; //導入方法依賴的package包/類
public static String formatGpsGsa(GpsStatus gps) {
String fix = "1";
String prn = "";
int nbr_sat = 0;
Iterator<GpsSatellite> satellites = gps.getSatellites().iterator();
for (int i = 0; i < 12; i++) {
if (satellites.hasNext()) {
GpsSatellite sat = satellites.next();
if (sat.usedInFix()) {
prn = prn + sat.getPrn();
nbr_sat++;
}
}
prn = prn + ",";
}
if (nbr_sat > 3)
fix = "3";
else if (nbr_sat > 0)
fix = "2";
//TODO: calculate DOP values
return fix + "," + prn + ",,,";
}
示例7: onGpsStatusChanged
import android.location.GpsSatellite; //導入方法依賴的package包/類
@Override
public void onGpsStatusChanged(int event) {
switch (event) {
case android.location.GpsStatus.GPS_EVENT_STARTED:
break;
case android.location.GpsStatus.GPS_EVENT_SATELLITE_STATUS:
satellites.clear();
gpsStatus = locationManager.getGpsStatus(gpsStatus);
for (GpsSatellite sat : gpsStatus.getSatellites()) {
if (sat.usedInFix()) {
satellites.add(sat);
}
}
break;
case android.location.GpsStatus.GPS_EVENT_FIRST_FIX:
break;
case android.location.GpsStatus.GPS_EVENT_STOPPED:
break;
}
}
示例8: analyze
import android.location.GpsSatellite; //導入方法依賴的package包/類
private void analyze() {
if (satellites != null) {
return;
}
satellites = status.getSatellites().iterator();
maxSatellites = status.getMaxSatellites();
satCount = 0;
satUsedInFixCount = 0;
while( satellites.hasNext() ) {
GpsSatellite satellite = satellites.next();
satCount++;
if (satellite.usedInFix()) {
satUsedInFixCount++;
}
}
}
示例9: onGpsStatusChanged
import android.location.GpsSatellite; //導入方法依賴的package包/類
@Override
public void onGpsStatusChanged(int event) {
GpsStatus status = mLocationManager.getGpsStatus(null);
int satsUsed = 0;
Iterable<GpsSatellite> sats = status.getSatellites();
for (GpsSatellite sat : sats) {
if (sat.usedInFix()) {
satsUsed++;
}
}
if (satsUsed == 0) {
if (mStatus != GPS_INACTIVE)
mStatus = GPS_SEARCH;
showStatusNoLocation();
}
}
示例10: onGpsStatusChanged
import android.location.GpsSatellite; //導入方法依賴的package包/類
/**
* Called when the status of the GPS changes. Updates GPS display.
*/
public void onGpsStatusChanged (int event) {
GpsStatus status = locationManager.getGpsStatus(null);
int satsInView = 0;
int satsUsed = 0;
Iterable<GpsSatellite> sats = status.getSatellites();
for (GpsSatellite sat : sats) {
satsInView++;
if (sat.usedInFix()) {
satsUsed++;
}
}
if (gpsSectionFragment != null) {
gpsSectionFragment.onGpsStatusChanged(status, satsInView, satsUsed, sats);
}
if (mapSectionFragment != null) {
mapSectionFragment.onGpsStatusChanged(status, satsInView, satsUsed, sats);
}
}
示例11: updateGPSInfo
import android.location.GpsSatellite; //導入方法依賴的package包/類
private void updateGPSInfo(GpsStatus s) {
boolean fixed = false;
int n = 0;
int u = 0;
if (s != null) {
Iterator<GpsSatellite> iterator = s.getSatellites().iterator();
while (iterator.hasNext()) {
GpsSatellite g = iterator.next();
n++;
if (g.usedInFix()) {
u++;
fixed = true;
}
}
}
gpsInfo.fixed = fixed;
gpsInfo.foundSatellites = n;
gpsInfo.usedSatellites = u;
Log.d(TAG, "updateGPSInfo : " + gpsInfo);
}
示例12: getNumSatsInFix
import android.location.GpsSatellite; //導入方法依賴的package包/類
private int getNumSatsInFix(LocationManager locationManager) {
if (ContextCompat.checkSelfPermission(this,Manifest.permission.ACCESS_FINE_LOCATION)!= PackageManager.PERMISSION_GRANTED) {
CustomLog.e(TAG,"Logic error. no permissions to get number of satellites in fix. Cannot continue");
return Constants.INVALID_NUMBER_OF_SATS;
}
int numSats=0;
int numSatsInFix=0;
for (GpsSatellite sat : locationManager.getGpsStatus(null).getSatellites()) {
if(sat.usedInFix()) {
numSatsInFix++;
}
numSats++;
}
return numSatsInFix;
}
示例13: calSatelliteUseInFix
import android.location.GpsSatellite; //導入方法依賴的package包/類
public static int calSatelliteUseInFix(List<GpsSatellite> satellites) {
int count = 0;
for (GpsSatellite s : satellites) {
if ((s.getPrn() > 0) && s.usedInFix())
count++;
}
return count;
}
示例14: onGpsStatusChanged
import android.location.GpsSatellite; //導入方法依賴的package包/類
@Override
public void onGpsStatusChanged(int arg0) {
switch (arg0) {
case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
GpsStatus gpsStatus = mLocationManager.getGpsStatus(null);
int usedinfix = 0;
if (gpsStatus != null) {
Iterator<GpsSatellite> satellites = gpsStatus
.getSatellites().iterator();
if (satellites != null) {
while (satellites.hasNext()) {
GpsSatellite satellite = satellites.next();
if (satellite.usedInFix()) {
usedinfix++;
}
}
}
}
mUsedInFix = usedinfix;
if (mUsedInFix < 3) {
updateGpsSpeed(-1);
}
break;
case GpsStatus.GPS_EVENT_STARTED:
break;
case GpsStatus.GPS_EVENT_STOPPED:
break;
}
}
示例15: onGpsStatusChanged
import android.location.GpsSatellite; //導入方法依賴的package包/類
@Override
public void onGpsStatusChanged(int event) {
if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) {
// Count fixed/visible satellites
int fixed = 0;
int visible = 0;
LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE);
for (GpsSatellite sat : lm.getGpsStatus(null).getSatellites()) {
visible++;
if (sat.usedInFix())
fixed++;
}
// Persist fixed/visible satellites
Log.i(TAG, "Satellites fixed/visible=" + fixed + "/" + visible);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(GpsStatusService.this);
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(SettingsFragment.PREF_SATS_FIXED, fixed);
editor.putInt(SettingsFragment.PREF_SATS_VISIBLE, visible);
editor.apply();
// Send state changed intent
Intent intent = new Intent(GpsStatusService.this, BackgroundService.class);
intent.setAction(BackgroundService.ACTION_STATE_CHANGED);
startService(intent);
}
}