Tecnologia do Blogger.
RSS

Re: [androidbrasil-dev] KM/h via GPS

  Achei isto no google     http://stackoverflow.com/questions/4811920/why-getspeed-always-return-0-on-android  
    String provider = initLocManager();
   
if (provider == null)
       
return false;
   
LocationListener locListener = new LocationListener() {
       
public void onLocationChanged(Location location) {
            updateWithNewLocation
(location, interval, startId);
           
Log.i(getString(R.string.logging_tag), "speed =" + location.getSpeed());
       
}

       
public void onProviderDisabled(String provider){
            updateWithNewLocation
(null, interval, startId);
       
}

       
public void onProviderEnabled(String provider) {}
       
public void onStatusChanged(String provider, int status, Bundle extras) {}
   
};

    _locManager
.requestLocationUpdates(provider, interval,  DEFAULT_GPS_MIN_DISTANCE, locListener);


   
private String initLocManager() {
   
String context = Context.LOCATION_SERVICE;
    _locManager
= (LocationManager) getSystemService(context);

   
Criteria criteria = new Criteria();
    criteria
.setAccuracy(Criteria.ACCURACY_FINE);
    criteria
.setAltitudeRequired(false);
    criteria
.setBearingRequired(true);
    criteria
.setSpeedRequired(true);
    criteria
.setCostAllowed(true);
   
//criteria.setPowerRequirement(Criteria.POWER_LOW);
   
String provider = _locManager.getBestProvider(criteria, true);

   
if (provider == null || provider.equals("")) {
        displayGPSNotEnabledWarning
(this);
       
return null;
   
}

   
return provider;
  
  
  

Em 30 de maio de 2012 15:36, Douglas Alípio <douglas.alipio@gmail.com> escreveu:
Já existe um método que te retora a velocidade km/h

getSpeed 

da uma olhada nesse post!

http://www.krvarma.com/2010/07/getting-speed-of-the-device-using-gps-in-android/ 

Em 30 de maio de 2012 15:29, Robson Dourado <r.dourado007@gmail.com> escreveu:

Boa tarde, gostaria de saber se de algum modo há como calcular a
velocidade que o usuário do Smartphone esta.

No Aguardo.



--







Atenciosamente,
Douglas Alípio Mesquita



  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comentários:

Postar um comentário