Search code examples
androidgeolocationgoogle-places-apiandroid-wifiandroid-location

How to detect that you are in the building using some Google /Location API on Android


I need to detect when I enter into building from the street. Now I use the next: if your device are connected to the wifi - you are into the building. I use WifiManager.NETWORK_STATE_CHANGED_ACTION for that. But this is not entirely accurate, because there are many free zone wi-fi, in the park for example. Please tell me how can I solve my problem ? Give me some link or advice. Maybe there a some way to define that the current wireless access point is public and it located into park or what ?


Solution

  • As I can see it, you have two options:

    1. Try to understand when you stop getting GPS signal for a long period of time. GPS will only work outside so it should give you good results, you can also try to understand how many satellites the GPS sees and check when that number drops.
    2. You can try to use the pressure sensor (barometer) to detect altitude, if the altitude raises quickly, it could mean that the user is using an elevator. How to get barometric altitude in Android?

    A combination of the two could lead to a good solution.