Experience of Location Services on Android using G

2019-07-18 04:52发布

问题:

I have written a piece of code to get a feel of what my customer (cab driver) will experience when I enable location services on his device for my cab booking application. I enabled location services using both Network and GPS providers on the same listener.

LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
    // God.KM20TIME, God.KM20DISTANCE, (LocationListener) updates);

lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, God.KM20TIME,
            God.KM20DISTANCE, (LocationListener) updates);

My battery ran out much faster than normal. I also had my phone heating up more than normal. But the consistency I was expecting was really low. I have decided to not use GPS, and only Network provider. I am building a cab booking app, so I need to know where the cab is approximately. Even if I know that the cab was at a approximate (300 meters) location about 15 mins back, I should be good. So I guess my decision to not over engineer this logic by using both providers is correct. I wonder if anyone can relate to a different experience here ? Am I missing something ?

回答1:

From my experience, the quality of the Network provider can vary quite a bit.

The network provider uses a combination of WiFi and Cell tower information to provide location information.

If you happen to be close to a Wifi network, which is common in urbanized areas, but not outside of cities, you usually get a very good accuracy.

However, outside of range of a Wifi, you're at the mercy of the cell towers. Here, the precision depends on the quality and features of the cell tower, as well as the amount of cell towers that can be used to triangulate your position.

In these situations, the quality can vary alot, both between locations, but also depending on which Carrier you use, the distance between their cell towers, but also what make and generation of cell towers they have. Newer have more features regarding location, and might for example provide bearing on its own.

My application runs in Sweden, and in some areas of our country, a carrier might have only one tower within a very large area. In those cases, all lon/lat fixes end up directly on the tower, with a precision of even up to 20.000 - 30.000 meters.

Basically, my point is that when using the network provider, if you're not near a Wifi, i'd be very satisfied with 300 meters accuracy.

Regarding the battery / heat - with your requirements, you can play around a lot with the time / distance parameters to get a "good enough" update frequency that doesn't tax the phone as much.