title: Getting Speed from GPS or Network Provider
body: <p>I am creating an application to get speed from GPS and Network provider. I am trying basics first with the following code:</p>
  
  <pre><code>LocationManager locationManager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); 
  
  
      LocationListener locationListener = new LocationListener() 
      {
          public void onLocationChanged(Location location) 
          { 
  
              //location.getLatitude(); 
              speedText.setText("Current speed:" + location.getSpeed());
  
          } 
  
          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);
  
  //locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
  </code></pre>
  
  <p>With Manifext permissions:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
  &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  </code></pre>
  
  <p>With the above code I get only 0.0 as the value always. Both GPS and Network give the same value. I am not sure where I am going wrong? Can somebody help me fix this part please?</p>
  
  <p>Thanks!</p>