android-studioandroid-gps

How to track movements in a room with Android Studio?


The need is to track the user moving in small areas (for example at home, in a garden, in a museum, or in some rooms) with Android Studio (Java) drawing the path he does on the screen.

I can use StepCouter to count the user steps and the distance walked. But what about the path? I thought of using the GPS location but his best accuracy (PRIORITY_HIGH_ACCURACY) is between 10 and 100 meters, non enough for a house (unless you have a huge villa).

So how to track (and draw) the path in small areas?


Solution

  • A couple of solutions:

    1. Using Bluetooth Low Energy (BLE) beacons to track indoor positioning.

    2. Using an external GPS (outdoors) using mock location in developer mode on Android. Instructions on how to do that can be found here.

    Use these permissions in the Android Manifest:

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
    

    You'll need to activate mock location in the developer settings on the Android device and then connect the external GPS via bluetooth.