Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I agree with most of comments from AlexBottoni good answer, although in some points I can't suppot him.</p> <p><strong>Overview</strong></p> <p>First, just to check that you are doing it right... </p> <p>You setup the same <code>LocationListener</code> for both providers. To indentify from where you are reciving the location you need to test it like this:</p> <pre><code>public void onLocationChanged(Location fix) { if(fix.getProvider().equals(LocationManager.GPS_PROVIDER)){ //here Gps } else if(fix.getProvider().equals(LocationManager.NETWORK_PROVIDER)){ //here Network } </code></pre> <p>Also, you setup a different acquisition frequency. <code>Gps</code> is providing a new location every 30 seconds and <code>Network</code> every 2 minutes.</p> <p>As you didn't impose a minimum distance, you should receive a new <code>Location</code> from each one of the providers (as long as they can get a fix) with the frequency requested. If you don't receive a fix, is because they weren't able to acquire one. </p> <p>Also, it may takes a little longer then requested to get the fix (mainly with Gps), because it may take some time to shyncronize with satellites and fix a location.</p> <p><strong>Fallback</strong></p> <p>There is no builted-in fallback from one provider to the other. They are independet, as said by Alex. I'm using the following approach to implement fallback:</p> <ul> <li>Register Gps listener and start a timer</li> <li>On every GPS location, restart timer</li> <li>If timer reachs end, register Network listener (Gps listener keeps registered)</li> <li>If new Gps location arrives, unregister Network listener, restart timer</li> </ul> <p><strong>Preferable Provider</strong></p> <p>Although <code>Gps</code> may not be available everyhere, is far most precise then <code>Network</code>. In my town, I get 6 meters accuracy with GPS and 1 Km with Network :-(</p> <p><strong>Two services</strong></p> <p>Doesn't matter where you register the listener, activity or service, separate ot together, as long as you request them and the provider can get a fix, you will get the location (assuming no bugs in application :-))</p> <p><strong>Final Notes</strong></p> <p>Ensure you have the permissions need (ACCESS_FINE_LOCATION, INTERNET, etc).</p> <p>Ensure that phone setup have Network Location enabled (usually default is disable)</p> <p>Most Gps receivers support updating information about satellite location, which improves fix time. You can use <code>GPS Satus</code> from the market, to do it.</p> <p>Regards.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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