Search code examples
androidgpslocationmanagerlocationlistener

force update many times :Gps Location during 3-6 seconds


my app need use new current GPS parameter(update after each from 3 to 8 second): latitude and longitude. and i am using both: GPS-provider and Network-provider. i know use to update the GPS parameters

if(gps_enabled)
     lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListenerGps);

if(network_enabled)
     lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListenerNetwork);

The Problem: in fact, the gps update after each environ 40-50 second

How can i get the GPS update after 3-8 seconds ??

thanks you


Solution

  • try{gps_enabled=lm.isProviderEnabled(LocationManager.GPS_PROVIDER);}catch(Exception ex){}
                    try{network_enabled=lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER);}catch(Exception ex){}
    

    //lm is locationManager

    In fact. i don't use the condition: network_enabled or Network-provider to get Location. ---> It work and the new code:

     lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 0, locationListenerGps);
    

    The reason, i don't use the Network_Provider. Because, when 2 GPS and Network Provider, system will use the NEtwork_provider. But in the logcat, i see that Smartphone does not update"Listenter" loop 3-6s with Network_provider. En revanche, with GPS_PROVIDER, smartphone update alway 3-6s.

    -- First time when open GPS; i need 30-50second to have the first Listener. But it is OK