Skip to content

Repository files navigation

CircleCICodacy Badge

Asset Tracker Service for Android

This android app runs a background service that saves the device location, speed, direction and other measurements every 10 seconds to a google firestore database. The full location history is available for live or deferred analysis.

Deploying the app to an android phone

  1. Install Android Studio.
  2. Clone or download this repository.
  3. Create a Firebase account because data is saved there. The free account is sufficient. See console.firebase.google.com
    1. In Firebase create a project, for example "asset-tracker".
    2. Navigate to Develop / Database and open the Rules tab. Replace the contents with the content of the file firestore.rules. Click publish.
    3. Navigate to Authentication / Sign-in method and enable the Google sign-in provider.
    4. Navigate to Project settings. There click on the android icon on the bottom.
      1. For Android package name enter "com.example.assettracker".
      2. For Debug signing certificate SHA-1, enter the debug certificate SHA1 key. The command to get it is documented here. The SHA1 key is needed for Google Sign-in.
      3. Click Register app and then click Download google-services.json.
  4. Copy the downloaded google-services.json to the /app folder.
  5. Open the project in Android Studio.
  6. Connect your android device with a usb cable.
  7. Developer mode must be enabled on your phone.
  8. Click Run or click Debug. The app will be compiled and be installed on your phone.
  9. The app will ask you to log-in with your google account. This is only required the first time the app starts. Even after a reboot you do not need to log-in again.
  10. A bus icon appears in the status bar to indicate that the service is running. Click it to stop the app.

Accessing the location data

To see the generated data, login to the firebase account (see above) then navigate to Database and open the Data tab. You can access the Google Firestore database from android, iPhone or a web app. Firestore can push data modifications to clients.

Saved data

Users: /users/{userUid}

  • A user must have a google account but different log-in methods can be activated.
  • A user may generate measurement data for zero or more devices.
  • A user can read data hat s/he generated.
  • A user can read data from other users if the other users grant permission.
{userUid: "qDrkd0i898cjJhEo3MDJZaxe2gO",// Type stringemail: "test@gmail.com",// Type stringdisplayName: "Test User",// Type stringaccountCreatedAt: 2May2020at20:16:40UTC+2,// Type timestampauthorizedUsers: ["pBc0SizEabPHtdB9FRkLDZycCq32"]// Type array of string}

Devices: /users/{userUid}/devices/{deviceId}

{deviceId: "erEXZrc6QMOZgOL4YTLTlo",// Type stringmanufacturer: "CUBOT",// Type stringmodel: "CUBOT ECHO",// Type stringapi: 23,// Type numberfirstLoginAt: 15May2020at13:04:56UTC+2// Type timestamp}

Location-Measurements: /users/{userUid}/devices/{deviceId}/location-measurements/{timestamp}

{geoPoint: [50.4214267°N,8.355768°E],// Type geopointhorizontalAccuracyMeters: 22.291000366210938,// Type numberbearing: 271.8037109375,// Type number; horizontal direction of travel in degrees 0.0-360.0speed: 0.10250464826822281,// Type number; meters/secondtime: 4May2020at07:16:40UTC+2// Type timestamp}

Log Messages: /users/{userUid}/devices/{deviceId}/logs/{timestamp}

{time: 5May2020at22:44:37UTC+2,// Type timestampmessage: "App started",// Type stringlevel: "INFO"// Type string}

Other things to know

  • The app will not start automatically after a reboot. You need to click the app icon "Asset Tracker".
  • If the internet connection is lost, the location is recorded on the device and synced once the connection is reestablished.

Screenshots

Author

David Neuy

License

MIT

About

Saves the device location every 10 seconds to firestore database.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages