Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid requestLocationUpdates failing
    text
    copied!<p>I am developing a proximity alert related project. For that whenever I opened my app, I need to get exact readings of where I am. Even though I am following the right coding practices prescribed by android documentation, I am not getting the expected result.</p> <p>Why there is no alternative command in entire android Geolocation coding for getLastKnownLocation which will give us where we are earlier not now.</p> <p>I have did one javascript coding in the same lines. There My code is working properly. The Descriptive address and coordinates where my device is working nice there. Those commands getCurrentPosition and watchPosition are givinga beautiful response via their event handler callbacks. Why there is no getCurrentLocation in android geolocation parlance?</p> <p>Even though I have followed relevant coding practices, MyLocationListener myLocationUpdate which implements LocationListener is not updating my new location when I am moving from one place to another place. I gave MINIMUM_DISTANCE_CHANGE_FOR_UPDATES as 1(in meters) and MINIMUM_TIME_BETWEEN_UPDATES as 1000 (in milliseconds).</p> <p>I am giving important code snippets below to understand the problem</p> <h2>in onCreate handler of the activity</h2> <pre><code> locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); boolean enabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); if (!enabled) { Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(intent); } Criteria criteria = new Criteria(); provider = locationManager.getBestProvider(criteria, false); myLocationUpdate = new MyLocationListener(); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,MINIMUM_TIME_BETWEEN_UPDATES,MINIMUM_DISTANCE_CHANGE_FOR_UPDATES, myLocationUpdate); retrieveLocationButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(MainActivity.this,"Finding Location",Toast.LENGTH_LONG).show(); showCurrentLocation(); } }); latituteField = (TextView) findViewById(R.id.display_Location); </code></pre> <h2> showCurrentLocation();</h2> <p>in showCurrentLocation function I am using locationManager.getLastKnownLocation(provider) to retrieving that location. By using GeoCoder Object and the command geocoder.getFromLocation(latitude, longitude, 1) to get First Address match for the coordinates. // internal class to handle location cahnge event private class MyLocationListener implements LocationListener contains all the Overridden functions including public void onLocationChanged(Location location) But Practically I am getting nothing out of all the application. I have already recorded Time via location.getTime(). It is showing a fixed earlier time, but not the interval i specified.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload