Note that there are some explanatory texts on larger screens.

plurals
  1. PONetwork provider generates a 2 copies of a location
    primarykey
    data
    text
    <p>I'm trying to generate a location first through the gps provider if I get a null I'm generating through the network provider. My problem is that the network provider generates the same location twice.. I send the information to the db and it sends the same location with the same time(same seconds!). Here is some code:</p> <pre><code>gpsLocation = requestUpdatesFromProvider(LocationManager.GPS_PROVIDER, R.string.not_support_gps); networkLocation = requestUpdatesFromProvider(LocationManager.NETWORK_PROVIDER, R.string.not_support_gps); // Update the UI immediately if a location is obtained. if (gpsLocation != null) updateUILocation(gpsLocation); else updateUILocation(networkLocation); </code></pre> <p>Here is the requestUpdateFromProvider:</p> <pre><code>private Location requestUpdatesFromProvider(final String provider, final int errorResId) { Location location = null; if (mLocationManager.isProviderEnabled(provider)) { mLocationManager.requestLocationUpdates(provider, TEN_SECONDS, TEN_METERS*2, listener); location = mLocationManager.getLastKnownLocation(provider); } else { Toast.makeText(this, errorResId, Toast.LENGTH_LONG).show(); } return location; } </code></pre> <p>Here is the updateUILocation:</p> <pre><code>private void updateUILocation(Location location) { // We're sending the update to a handler which then updates the UI with the new location. Message.obtain(mHandler, UPDATE_LATLNG, location.getLatitude() + ", " + location.getLongitude()).sendToTarget(); // Bypass reverse-geocoding only if the Geocoder service is available on the device. if (mGeocoderAvailable) doReverseGeocoding(location); } </code></pre> <p>Here is the handler:</p> <pre><code> mHandler = new Handler() { public void handleMessage(Message msg) { if(msg.what == UPDATE_ADDRESS) //UPDATE_ADDRESS = 1 { LocationService.this.address = (String) msg.obj; // update a string that show the user address new SendLocation(LocationService.this.id,(String)msg.obj);//send the info to the db. } } }; </code></pre> <p>The SendLocation is doing what it suppose to do correctly so you shouldn't pay attention to it.</p> <p><strong>EDIT</strong></p> <p>I forgot to say that the first piece of code is a method called from the constructor.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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