title: value of current speed freeze when the app is minimized
body: <p>I am working on a simple app to get the speed of the device to use it to calculate the speed of the car.
  I have a variable where I store the value of current speed and I have a problem when the app is minimized this value freeze and doesn't change and I want to change whether the is app is minimized or not,</p>
  <p>I tried adding the below permission but it didn't work,</p>
  <pre><code>  &lt;uses-permission android:name=&quot;android.permission.ACCESS_BACKGROUND_LOCATION&quot; /&gt;
  </code></pre>
  <p>here is the code I am using to get the value of current speed:</p>
  <pre><code>  float nCurrentSpeed;
  
    @Override
    public void onLocationChanged(Location location) {
  
       num = Integer.valueOf(tv.getText().toString());
  
      if (location == null) {
  
          txt.setText(&quot;0.0&quot;);
      } else {
          nCurrentSpeed = location.getSpeed() * 3.6f;
          txt.setText(String.format(&quot;%.2f&quot;, nCurrentSpeed) + &quot;&quot;);
      }
  </code></pre>
  <p>}</p>