10

Issue:

Location updates not working indoors as claimed by Fusion Location Provider APIs.

What happened:

  1. I tried implementing the latest location API to get location updates using LocationClient in my Android App.
  2. My android app works fine with out any issue while I am testing outdoor.
  3. But when testing indoors (inside any building), then no location updates are happening.

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" />
Whymarrh
  • 13,139
  • 14
  • 57
  • 108
talasila
  • 268
  • 1
  • 3
  • 9

4 Answers4

3

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)?

David
  • 749
  • 5
  • 2
  • Thanks for quick reply. I double checked, WiFi is enabled; under Location access, Wi-Fi & mobile network location is enabled; and sim card is also working. In google Maps the location accuracy says "1300 meters" when testing inside same building. But not getting location in my app. I will soon get the dump while running my app and will update you. – talasila May 29 '13 at 15:06
  • Based on the accuracy you get in Google maps you're receiving cell location indoors which means wifi location isn't available in your building. I'm guessing there's a bug where cell location isn't working for some reason. You might try in a place where wifi location is available (maybe in a mall). Not sure what causes this, but it will probably be fixed in a future version. – David May 29 '13 at 17:04
  • By the way, if you do post the dump, you might want to delete the lat/lng locations for privacy - up to you. – David May 29 '13 at 17:05
  • One more observation while testing Google Maps android app inside the building: 1) I moved to nearest WiFi router and started testing, then I got location accurate to 60 meters. 2) I switched off WiFi, then the accuracy is 1600 meters. But when I tried same test case using my app, I do not get any location update inside the building. – talasila May 29 '13 at 18:32
1

tinku! I've got the same issue with my Galaxy Nexus and Fusion Location Provider APIs.
My decision is setting priority for LocationRequest object to LocationRequest.PRIORITY_LOW_POWER

 mLocationRequest = LocationRequest.create();

 mLocationRequest.setPriority(LocationRequest.PRIORITY_LOW_POWER);

 mLocationRequest.setInterval(UPDATE_INTERVAL);
 mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
 mLocationClient = new LocationClient(this, this, this);


For me it works fine indoors (low accuracy) and outdoors (high accuracy). Hope it will help you.

0

Are you certain that you're not disconnecting the client? Once you disconnect the LocationClient, the current location update request disappears.

The code snippets by themselves are not a complete app. The sample app, however, is a complete working app. The purpose of the snippets is to show you the key steps, from which you can cut and paste. The sample app provides more material.

Joe Malin
  • 8,621
  • 1
  • 23
  • 18
  • Thanks for the reply. I double checked for the client using a Toast and it is connected. I got sample app and installed on to my phone. Even when testing with sample app inside a building I do not get location (same behavior as in my app). But in google Maps the location accuracy says "1300 meters" when testing inside same building at same time. Do you think Google Maps Android app code might be doing something extra checks which are not discussed in Open source APIs. – talasila May 29 '13 at 15:11
  • 1
    So you're saying that the sample app works outside the building but not inside, with no other changes. – Joe Malin May 29 '13 at 16:42
  • Yes no changes are made, I deployed the sample app as is. It works fine outside the building but not inside. – talasila May 29 '13 at 17:58
  • if location services are not enabled in the app by default and if i enable any of one location service using location intend, client is not reconnecting in onActivityResult method and cannot fetch the current location.how to solve this issue? – sooraj.e Jun 25 '13 at 05:52
0

After long testing and debugging on HTC One X (4.1.1), I decided to try same test cases on any other phone model. Luckily my app worked indoors too when testing with my friend's Samsung S3 (4.1.1). At same time and location, when I tested with my HTC One X, I do not get location indoors. Both phones are set with same settings (WiFi/GPS/Mobile network all enabled).

To confirm this is an issue with specific device, I performed many tests inside the building at different corners using my app and I see the same issue on my HTC at all indoor locations (but at same locations S3 gets the indoor location).

talasila
  • 268
  • 1
  • 3
  • 9
  • When you enabled PRIORITY_HIGH_ACCURACY, did you notice the GPS icon lighting up on your phone ? (meaning that the GPS radio was actively looking for satellites) ? – ddewaele Jun 28 '13 at 15:22