gps with NETWORK_PROVIDER

3

I am trying to position my location in an android application that I am developing. I was reading online that there are 3 types of providers and I read their differences so in the end I opted for NETWORK_PROVIDER but I can not understand if it is necessary to have the gps activated to work with the network.

    
asked by adamista 15.05.2016 в 21:03
source

1 answer

2

This is an interesting question, c When you use as provider NETWORK_PROVIDER , your device does not need to have the GPS enabled. You can have both providers enabled or one of them.

There are important differences that I think are important to comment:

  • If your geo-location services are determined by the Wi-Fi or mobile network, the battery consumption is low, but the accuracy of the position is not as reliable.

  • On the other hand, if your geo-location services are determined by GPS, the battery consumption is higher compared to the network provider, but the accuracy of the position is much better.

As I mention, you can use one or both providers, you can even individually determine the availability of one:

    private static boolean disponiblepGPS, disponibleRED;
    private static LocationManager locManager;
    private static String provider;

   //Determina si el NETWORK_PROVIDER esta disponible:
        try {
            disponibleRED = locManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
            provider = LocationManager.NETWORK_PROVIDER;
        } catch (Exception ex) {
            Log.e(TAG,"Error obteniendo NETWORK_PROVIDER.");
        }


     //Determina si el GPS_PROVIDER esta disponible:
        try {
            disponiblepGPS = locManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
            provider = LocationManager.GPS_PROVIDER;
        } catch (Exception ex) {
            Log.e(TAG,"Error obteniendo GPS_PROVIDER.");
        }

Currently, most devices can configure which providers to use to obtain geo-location. To obtain more accurately use the two providers A), to use only the network, with a low power consumption network B) or you can only use GPS C).

    
answered by 16.05.2016 / 04:31
source