[Solved] Calculating speed on an android phone [closed]


This is the example For calculating Speed of your android phone using GPS…

LocationManager mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        LocationListener mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
                mlocListener);



public class MyLocationListener implements LocationListener {

        @Override
        public void onLocationChanged(Location loc) {
            loc.getLatitude();
            loc.getLongitude();

            Geocoder gcd = new Geocoder(getApplicationContext(),
                    Locale.getDefault());
            try {
                mAddresses = gcd.getFromLocation(loc.getLatitude(),
                        loc.getLongitude(), 1);

            } catch (IOException e) {

            }

            String cityName = (mAddresses != null) ? mAddresses.get(0)
                    .getLocality() : TimeZone.getDefault().getID();
            String countryName = (mAddresses != null) ? mAddresses.get(0)
                    .getCountryName() : Locale.getDefault().getDisplayCountry()
                    .toString();


            mCurrentSpeed.setText(loc.getSpeed());
        }

        @Override
        public void onProviderDisabled(String provider) {
            Toast.makeText(getApplicationContext(), "Gps Disabled",
                    Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onProviderEnabled(String provider) {
            Toast.makeText(getApplicationContext(), "Gps Enabled",
                    Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {
        }
    }

1

solved Calculating speed on an android phone [closed]