Damir
Damir

Reputation: 56199

What is more quicker is seconds ans precise provider : GPS_PROVIDER or NETWORK_PROVIDER if both are enabled?

I need to find location with android. My question is what is more quicker is seconds ans precise provider : GPS_PROVIDER or NETWORK_PROVIDER if both are enabled ? Can you tell me how long it takes to return location, I am new to this stuff and don't have any idea about time .

Upvotes: 0

Views: 249

Answers (5)

Nar Gar
Nar Gar

Reputation: 2591

Also GPS provider works only outdoors, Network provider works indoors as well.

Upvotes: 0

ArcDare
ArcDare

Reputation: 3106

GPS => More accurate, more time needed Network => Less accurate, less time needed

(And, of course, you can define your preferences about this with the object Criteria)

Upvotes: 0

Nibha Jain
Nibha Jain

Reputation: 8141

In my case i found that NETWORK_PROVIDER is quicker than GPS_PROVIDER , It is difficult to say that "how long it takes to return location" it's not same always...

Check this ,which i am using for retrieving the current location :

http://code.google.com/p/messesinfoandroid/source/browse/trunk/src/cef/messesinfo/maps/MyLocation.java?spec=svn12&r=12

Upvotes: 0

SERPRO
SERPRO

Reputation: 10067

You can select the Criteria yo want to get the best provider, like for example if your criteria is precision:

LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Criteria c = new Criteria();
c.setAccuracy(Criteria.ACCURACY_FINE);
final String PROVIDER = lm.getBestProvider(c, true); 

Also if you want quick location, you can get the last known location with a function like this (Extracted from here):

public static Location getLastKnownLocation(LocationManager locationManager)
{
    Location bestResult = null;
    float bestAccuracy = 0;
    long bestTime = 0;

    List<String> matchingProviders = locationManager.getAllProviders();

    for (String provider: matchingProviders) {
        Location location = locationManager.getLastKnownLocation(provider);
        if (location != null) {
            float accuracy = location.getAccuracy();
            long time = location.getTime();

            if ((time > minTime && accuracy < bestAccuracy)) {
                bestResult = location;
                bestAccuracy = accuracy;
                bestTime = time;
            }
            else if (time < minTime && 
                    bestAccuracy == Float.MAX_VALUE && time > bestTime){
                bestResult = location;
                bestTime = time;
            }
        }
    }

    return bestResult;
}

Upvotes: 1

Yashwanth Kumar
Yashwanth Kumar

Reputation: 29121

In general, GPS_PROVIDER, takes more time than NETWORK_PROVIDER considering that you are requesting for a new location. NETWORK_PROVIDER is generally quick, but GPS_PROVIDER , i can't tell you(i don't know) the exact time for this.

GPS is accurate over NETWORK.

Upvotes: 0

Related Questions