I am able to get location update or current location using LocationClient and LocationRequest.
But how to know whether the location is obtained is using gps provider or network provider.
Here is the sample code https://developer.android.com/training/location/retrieve-current.html
Apparently it is not possible while using
LocationClient
andLocationRequest
as the priority shifts from the source to the requirement/need side of obtaining thelocation
.The provider is Fused Location Provider:
Source: Location APIs Android
I tried to figure this out when they first introduced these api, even if you 'get' the 'provider' from the
location
object,i.e.
location.getProvider()
, it returns :"fused" as the value and not as GPS or NETWORK.Still if you want to deduce the source of location, not entirely accurate, but it can be related to the PRIORITY that is set with the help of LocationRequest
Example:
I have observed that depending on the PRIORITY set with
LocationRequest
, the use of GPS is altered.Only for PRIORITY_HIGH_ACCURACY does the app use GPS(not exclusively as its Fused Location Provider), hence for other two PRIORITY settings, it 'intelligently manages' the fused sources and provide the location with as much accuracy as possible, saving battery/power.
Please Note:
When set to PRIORITY_HIGH_ACCURACY, i don't mean that the GPS should be enabled to obtain location under that condition, just that if GPS is enabled, you can visually see that it is being used under that PRIORITY and is not being used when you set a different PRIORITY.
The Fused Location Provider uses GPS, WiFi, Cell Towers, and Sensors to determine accurate location estimate.
Have a look at The Google IO on Location API , it was good.
Useful presentation: Android Location
Blog: of 2013, but useful