How best to get the current speed in the application for Android?

    2 answers 2

    I can not leave a comment, look at this link: https://stackoverflow.com/questions/15570542/determining-the-speed-of-a-vehicle-using-gps-in-android

    Quite well disassembled question.

    • a link to en.so, perhaps many will be more helpful to your answer if you insert into it the main one of the link with translation into Russian and / or with your own explanations. - Alex

    The Location class has a getSpeed ​​() method, use it.

    LocationManager locationManager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { location.getLatitude(); Toast.makeText(this, "Скорость:" + location.getSpeed(), Toast.LENGTH_SHORT).show(); } public void onStatusChanged(String provider, int status, Bundle extras) { } public void onProviderEnabled(String provider) { } public void onProviderDisabled(String provider) { } }; locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);