android.location.LocationManager.getGpsStatus()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(418)

本文整理了Java中android.location.LocationManager.getGpsStatus()方法的一些代码示例,展示了LocationManager.getGpsStatus()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocationManager.getGpsStatus()方法的具体详情如下:
包路径:android.location.LocationManager
类名称:LocationManager
方法名:getGpsStatus

LocationManager.getGpsStatus介绍

暂无

代码示例

代码示例来源:origin: apps4av/avare

/**
 * 
 */
@Override
public void onGpsStatusChanged(int event) {
  if(null == mLocationManager) {
    return;
  }
  GpsStatus gpsStatus = mLocationManager.getGpsStatus(null);
  mGpsCallback.statusCallback(gpsStatus);           
}

代码示例来源:origin: Phantast/smartnavi

private void updateSats() {
  try {
    final GpsStatus gs = this.mLocationManager.getGpsStatus(null);
    int i = 0;
    final Iterator<GpsSatellite> it = gs.getSatellites().iterator();
    while (it.hasNext()) {
      it.next();
      i += 1;
    }
    if (BuildConfig.debug) {
      Log.i("Location-Status", "Satelites in range: " + i);
    }
    satellitesInRange = i;
  } catch (SecurityException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: ApolloAuto/apollo-DuerOS

@SuppressLint("MissingPermission")
  @Override
  public void onGpsStatusChanged(int event) {
    int satellites = 0;
    int satellitesInFix = 0;
    int timeToFix = mLocationManager.getGpsStatus(null).getTimeToFirstFix();
    for (GpsSatellite sat : mLocationManager.getGpsStatus(null).getSatellites()) {
      if (sat.usedInFix()) {
        satellitesInFix++;
      }
      satellites++;
    }
    LogUtil.i(TAG, satellites + " Used In Last Fix (" + satellitesInFix + ")");
    if (satellites > 10) {
      mGpsImg.setImageResource(R.drawable.gps_1);
    } else if (satellites > 0) {
      mGpsImg.setImageResource(R.drawable.gps_2);
    } else {
      mGpsImg.setImageResource(R.drawable.gps_3);
    }
  }
};

代码示例来源:origin: ApolloAuto/apollo-DuerOS

@Override
  public void onGpsStatusChanged(int event) {
    int satellites = 0;
    int satellitesInFix = 0;
    int timeToFix = mLocationManager.getGpsStatus(null).getTimeToFirstFix();
    for (GpsSatellite sat : mLocationManager.getGpsStatus(null).getSatellites()) {
      if (sat.usedInFix()) {
        satellitesInFix++;
      }
      satellites++;
    }
    LogUtil.i(TAG, satellites + " Used In Last Fix (" + satellitesInFix + ")");
    if (satellites > 10) {
      mGpsImg.setImageResource(R.drawable.ic_gps_1);
    } else if (satellites > 0) {
      mGpsImg.setImageResource(R.drawable.ic_gps_2);
    } else {
      mGpsImg.setImageResource(R.drawable.ic_gps_3);
    }
  }
};

代码示例来源:origin: ApolloAuto/apollo-DuerOS

@Override
  public void onGpsStatusChanged(int event) {
    int satellites = 0;
    int satellitesInFix = 0;
    for (GpsSatellite sat : mLocationManager.getGpsStatus(null).getSatellites()) {
      if (sat.usedInFix()) {
        satellitesInFix++;
      }
      satellites++;
    }
    LogUtil.i(TAG, "GpsStatus.Listener: " + satellites + " Used In Last Fix (" + satellitesInFix + ")");
    if (satellites > 10) {
      mGpsImg.setImageResource(R.drawable.ic_gps_1);
    } else if (satellites > 0) {
      mGpsImg.setImageResource(R.drawable.ic_gps_2);
    } else {
      mGpsImg.setImageResource(R.drawable.ic_gps_3);
    }
  }
};

代码示例来源:origin: BasicAirData/GPSLogger

public void updateSats() {
  try {
    if ((mlocManager != null) && (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)) {
      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;
    }
  } catch (NullPointerException e) {
    _NumberOfSatellites = NOT_AVAILABLE;
    _NumberOfSatellitesUsedInFix = NOT_AVAILABLE;
    Log.w("myApp", "[#] GPSApplication.java - updateSats: Caught NullPointerException: " + e);
  }
  //Log.w("myApp", "[#] GPSApplication.java - updateSats: Total=" + _NumberOfSatellites + " Used=" + _NumberOfSatellitesUsedInFix);
}

代码示例来源:origin: openbmap/radiocells-scanner-android

final GpsStatus status = lmgr.getGpsStatus(null);

代码示例来源:origin: labexp/osmtracker-android

break;
GpsStatus status = lmgr.getGpsStatus(null);

代码示例来源:origin: hzw1199/AndroidGpsStatus

synchronized (this){
  if (locationManager != null){
    gpsStatus = locationManager.getGpsStatus(null);

代码示例来源:origin: flyingrub/SpeedMeter

public void onGpsStatusChanged (int event) {
  switch (event) {
    case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
      GpsStatus gpsStatus = mLocationManager.getGpsStatus(null);
      int satsInView = 0;
      int satsUsed = 0;

代码示例来源:origin: Car-eye-team/Car-eye-device

GpsStatus gpsStatus=lManager.getGpsStatus(null);

代码示例来源:origin: stackoverflow.com

if (location == null) {
  locationManager.getGpsStatus(null);
  locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,MIN_TIME_BW_UPDATES,MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
  Log.d("GPS Enabled", "GPS Enabled");
      mGpsStatus = locationManager.getGpsStatus(mGpsStatus);          
      Iterable<GpsSatellite> satellites = mGpsStatus.getSatellites();
      int iTempCountInView = 0;

代码示例来源:origin: FussenYu/MVP_Project

@Override
public void onGpsStatusChanged(int event) {
  GpsStatus gpsStatus = locationManager.getGpsStatus(null);
  switch (event) {

代码示例来源:origin: stackoverflow.com

switch (event) {
case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
  GpsStatus status = manager.getGpsStatus(null);
  mSattelites = 0;
  Iterable<GpsSatellite> list = status.getSatellites();

代码示例来源:origin: wiglenet/wigle-wifi-wardriving

gpsStatus = locationManager.getGpsStatus(gpsStatus);
} catch (NullPointerException npe) {
  MainActivity.error("NPE trying to call getGPSStatus");

相关文章