Android LocationManager always returns the same old position
<p>I have a problem with my Android App. I want to receive location updates and wrote following code:</p>

<p>The onCreate:</p>

<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    requestPermission();
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
        locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 0, this);
        // Define the criteria how to select the location provider -&gt; use
        // default
        Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

        if (location != null) {
            onLocationChanged(location);
        }
    }

}
</code></pre>

<p>The onLocationChanged:</p>

<pre><code>@Override
public void onLocationChanged(Location location) {

    if (mMap != null) {
        setMoveToLocation(location, mMap.getCameraPosition().zoom);
    }

}
</code></pre>

<p>And the setMoveToLocation</p>

<pre><code>private void setMoveToLocation(Location location, float zoom) {
    // Add a marker at given location and move the camera
    int lat = (int) (location.getLatitude());
    int lng = (int) (location.getLongitude());
    Log.i("Location", "Lat: " + lat + ", Long: " + lng + " Time: " + location.getTime());
    LatLng pos = new LatLng(lat, lng);
    mMap.addMarker(new MarkerOptions().position(pos).title("Your position"));
    Log.i("Zoom", "Zoom: " + zoom);
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(pos, zoom));
}
</code></pre>

<p>See the output:
<a href="http://i.stack.imgur.com/DrP2x.png" rel="nofollow">Log output</a></p>

<p>It is always the same wrong position, I am not located at 51,7! GPS is definitely truned on, I receive the relevant notification and other apps like Google Maps or Here are working properly.
I am using a Huawei Honor 7 with Android 6.0.</p>

<p>Any ideas?</p>

<p>Thanks in advance,
Plebo</p>