user429400
user429400

Reputation: 3325

Using the GPS to detect whether an android device is indoors

The app which i'm writing need to somehow detect if an android device is indoors or outdoors. My goal is to detect if the user left a certain building as soon as possible. I tried to use the user location signals. I'm not initiating any GPS sampling since I don't want to waste too much battery power, so the only way to detect if a user left a building is to wait for him to be far enough from the place and then use location signals which were sampled by wifi or cell. The problem is that it takes quite some time for me to detect that the user left the building.

I know that when a user is indoors, his GPS signal is weaker. Can I somehow use the GPS status to find out if the user is indoors or outdoors? Will it be wasteful as initiating a GPS location sample?

Thanks.

Upvotes: 0

Views: 877

Answers (1)

StuStirling
StuStirling

Reputation: 16191

I don't think you can do what you want to do with the FusedLocationProvider as this uses WiFi and cell tower triangulation. You will need to use the LocationManager.

It is also difficult to detect if you're inside and as far as I know there is no definitive way of doing this. You can make informed guesses however.

In terms of detecting a "weak" GPS signal you have a few things you could check:

  • The number of satellites available to you. If a low number then you are either indoors or somewhere with poor satellite coverage.
  • The horizontal accuracy of a received GPS location. If this value is high it can be deemed as poor accuracy which could be because you're inside.
  • No location has been received for a period of time. This could be because you're inside.

Have you thought of doing other checks as well as GPS so if they're connected to WiFi it increases the likelihood of them being inside?

Upvotes: 1

Related Questions