Issue:
Location updates not working indoors as claimed by Fusion Location Provider APIs.
What happened:
LocationClient
in my Android App.Expected behavior:
As per the new APIs, I am expecting to get some estimated location around the building while I am indoors (as GPS do not find the satellite signal for accurate location).
I see that latest Google Maps android app works fine indoors with estimated location.
Question:
What else do I have to take care using new location APIs to get the location update indoors (accurate location is not required, low accuracy is also fine).
I am implementing the Android App using Android 4.2.2 version APIs. I am testing on HTC One X (OS v 4.1.1)
Below is the android code that I applied to get location updates using new APIs:
Step1:
mLocationClient = new LocationClient(this, this, this);
Step2:
// Create the LocationRequest object
mLocationRequest = LocationRequest.create();
// Use high accuracy
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
// Set the update interval to 5 seconds
mLocationRequest.setInterval(UPDATE_INTERVAL);
// Set the fastest update interval to 1 second
mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
Step3: inside onStart()
method - below line is added:
// Connect the client.
mLocationClient.connect();
Step4: inside onConnected()
method - below line is added:
mLocationClient.requestLocationUpdates(mLocationRequest, this);
Step5: inside onLocationChanged()
method - listening for location updates. This method is not called when testing insides. This method is getting called only when GPS signal is found.
double lat = location.getLatitude();
double lng = location.getLongitude();
Finally added below permissions in Android Manifest:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Using the fused location provider API, your app can request the last known location of the user's device.
The accuracy values are typically more than 10 meters, while a third party GPS app (such as GPS test) typically reaches better accuracy if I wait long enough.
Make a location request Once a location request is in place you can start the regular updates by calling requestLocationUpdates() . Depending on the form of the request, the fused location provider either invokes the LocationCallback.
Based on your snippets your code looks fine to me for receiving indoor locations.
Try doing a dump while your app is requesting locations and you are indoors (expecting to receive locations but not): adb shell dumpsys activity service com.google.android.location.internal.GoogleLocationManagerService
Can you post the output here?
Can you double check that Settings->WiFi is enabled, and that Settings->Location access->Wi-Fi & mobile network location is enabled (both are required for indoor location).
Does your phone have a sim card? This would allow cell tower derived locations when wifi isn't available.
Finally you said that Google Maps gives you a location indoors in the same building. What is the approximate size of the accuracy circle (i.e. is it closer to 20 meters or 100 meters)?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With