Android LocationManager Criteria

前端 未结 3 1861
长情又很酷
长情又很酷 2021-01-12 11:18

I need to receive location changes both from Network and GPS providers.

If GPS provider not avaliable or has not location (bad sattelite visibility) I would receive

3条回答
  •  既然无缘
    2021-01-12 11:57

    For search best location Provider please user belowe code : Please refer https://developer.android.com/reference/android/location/Criteria.html for understand, How criteria will going to work ?

    public  String getProviderName() {
        LocationManager locationManager =(LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
        Criteria criteria = new Criteria();
        criteria.setPowerRequirement(Criteria.POWER_LOW);
        criteria.setAccuracy(Criteria.ACCURACY_FINE);
        criteria.setSpeedRequired(true);
        criteria.setAltitudeRequired(false);
        criteria.setBearingRequired(false);
        criteria.setCostAllowed(false);
        return locationManager.getBestProvider(criteria, true);
    }
    

提交回复
热议问题