When I use the GPS library, I can get a list of satellites, each with a flag that tells whether the satellite is being used for the current reading or not. Why would it not be used? What decides if a satellite is "used" or not?
It only needs a certain number of satellites. So, when it gets more than that, it selects them based on signal strength and position to get the best accuracy.
Think of it like this:
What the reciever actually gets is the (very accurate) distance from each satellite, and it knows the position of the satellite. It also gets a very accurate time, as that is needed for the position of the satellite. It does not, however, get the direction to the satellite.
So, with one sat, you basically know that you are somewhere on a bubble of a known radius. That's not very useful, but at least you know what time it is.
With two sats, you know that you are somewhere on the intersection of two bubbles. That means that you are somewhere on a circle. Not really useful, but at least you still know the time.
With three sats, it starts to get interesting. Now, we have the intersection of three bubbles (which means two possible points, as the third bubble cuts the previous circle). Since the satellites are overhead, you get one point on the ground and one in space. Most navigators assume that it's the one on the ground that's correct (although I've seen at least two that bug and give the space coordinate at the Dead sea, as it's level is about 500 m below sea level). All in all, you get a fairly crappy altitude with three sats.
With four, however, not only is the false point eliminated, we also get a much more accurate (read this as "useable", which a 3 sat reading altidude isn't) altitude. And we still know what time it is!
Beyond four sats, there is not much to gain, and some potential errors which require more expensive devices to sort out may occur, so usually, only four sats are used. Some devices may seem to use more, but they are mostly "put on hold" as spares, so if one sat is lost, it can pick up another quicker.
Now, why is the position important? Well, you want all those intersecting bubbles to intersect at as close to right angles as possible for maximum accuracy. A simple experiment to illustrate:
Draw two lines on a paper which cross at right angles. Then draw another two which are almost parallel. Which crossing will move the most if you nudge one of the lines a tiny bit?
So, short version: only four satellites are actually needed.
Thank you both for your info. I now understand better. The reason for my question is that sometimes my phone lists several satellites (more than 4) but none of them are used and no position is available. I don't know why.
You can get latitude and longitude from any WiFi, you don't need user/password to get that information
from wifi, sometimes you will get 24 meters accuracy.
Also if there is not wifi , not gps you can get location by cell operator, you will get accuracy between 20 meters - 2000 meters.