سؤال

In my android application i am using location manager to get the location . It works fine in below android 4.0.But in the later versions of android I find it difficult to get the network location in this Location manager API.That is location changed event for network provider is not called.

so I have moved to Location Client which uses play services to give accurate location to the application but in this API network location problem was solved.It gives some accurate locations to my application but it always return location.getSpeed() as Zero.

so is there any way to get speed value while using location client API.some body help me to sort this thing out.

هل كانت مفيدة؟

المحلول

The Google Play services LocationClient is a fused provider and will pick a location on your behalf from a mixture of the GPS on the device as well as the network based provider. It does this through a mixture of criteria and based on available resources. As a result there is no guarantee of the speed being set on the location that you receive and unfortunately it cannot be forced.

You will either have to switch back to using the LocationManager if you want to receive the speed with the location, or calculate the speed based on the location you are receiving from the device in your own code.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top