日本語

TUTORIAL - Automatic update of the device location data

Table of contents

1. Introduction
2. Methods for tracking the Android device location
3. Changes of the main screen layout
4. Settings to handle Android device location
4.1 Settings of the Android system
4.1.1 Move to the location menu in the system settings
4.1.2 Settings to get a more accurate location(Android 8)
4.1.3 Settings to get a more accurate location(Android 9+)
4.2 Settings on the Sensor Application side
4.2.1 Move to the location menu in the Application settings
4.2.2 Location settings per operation mode

1. Introduction

Sensor readings collected by the Sensor application is published as a JSON format. The JSON data has device section which can optionally convey the geographic position (latitude, longitude) of the Android device.

{
    "device": {
        "sysinfo": {},
        "userinfo": {},
        "location": {
            "latitude": "139.767120",
            "longitude": "35.681236"
        }
    },
    "sensors": []
}

If the Android device which runs the Sensor application is placed on a fixed place, there is nothing special to set the known location manually. On the other hand, if the Android device is placed on a vehicle, it is ideal to continuously monitor the device location and reflect the latest value to the output JSON data. This document shows the Sensor application usage and required system settings to realize the latter purpose.

There may be some differences in screen layout or system message expressions, depending on the Android system version. Please read accordingly to your Android device running environment.

2. Methods for tracking the Android device location

Android system has some mechanisms to track the device location, and registered user applications can get notifications of latest values at certain timings. With this implementation of the Sensor application, user can specify the location source (either via GPS or FLP), to automatically update the device location.

References

3. Changes of the main screen layout

Sample screen images with location enabled

By enabling the location feature in the Sensor application settings, current location per setting mode (FIXED, GPS or FLP) will be displayed in the main screen, as shown ‘label 2’ in the figure. If the automatic location update feature is enabled, a compass icon appears to indicate the location service is running (‘label 1’ in the figure).

4. Settings to handle Android device location

In the Android system, device location is considered as a subject to privacy protection. Any application accessing to the device location must fulfill the following conditions simultaneously [1][2].

References

4.1 Settings of the Android system

4.1.1 Move to the location menu in the system settings

Move to the location settings

In the system settings screen (a), find the location-related menu items. Follow menu hierarchy “1 -> 2” as shown above, and move to the location settings screen (c). There may be differences in screen structure or menu hierarchy based on Android versions, but please reach to the location settings screen in the end.

4.1.2 Settings to get a more accurate location(Android 8)

Required System Settings (Android 8)

To enable automatic location update with Sensor application, following 3 items must be set as specified. Here we present operational images on Android 8 system.

No. Settings Value Notes
1 Location ON  
2 Mode High accuracy Device only is also OK
3 App-level permissions Set ON for Sensor application  

System settings are applied for all applications on the device, and thus the values shown above might be different from what Sensor application expects. These settings values might have been changed for any reasons. If so, some dialogs will be shown at the Sensor application run time to prompt user to change system settings accordingly. Please follow such dialogs and satisfy above settings conditions.

4.1.3 Settings to get a more accurate location(Android 9+)

Required Settings (Android 9+)

Starting from Android 9, traditional location mode selection has deprecated. Instead, new menu item "Google Play services" collectively handles several Location services. In this case, the "Google Location Accuracy" is the subject of interest here.

To enable automatic location update with the Sensor application, following 3 items must be set as specified.

No. Settings Value Notes
1 Location ON  
2 App-level permissions Set ON for Sensor application  
3 Location services Set ON for Google Location Accuracy Hiding under the Advanced menu

System settings are applied for all applications on the device, and thus the values shown above might be different from what Sensor application expects. These settings values might have been changed for any reasons. If so, some dialogs will be shown at the Sensor application run time to prompt user to change system settings accordingly. Please follow such dialogs and satisfy above settings conditions.

References
The mapping of location settings between Android 8 and 9+ is shown below.

Android 8 Android 9+
Location: On/Off Location: On/Off
Mode: Battery Saver N/A
Mode: Device Only Location: On, Google Location Accuracy: Off
Mode: High Accuracy Location: On, Google Location Accuracy: On

4.2 Settings on the Sensor Application side

4.2.1 Move to the location menu in the Application settings

Move to the location settings screen

In the Application settings screen (a), find the Sensors menu item. Follow the menu hierarchy “1 -> 2” as shown above, and move to the location settings screen (c). Note that location settings is disabled as default state.

4.2.2 Location settings per operation mode

Location settings per operation mode

To use device location, enable the global switch (1) at first.

Then you have two choices depending on the usage; whether to put the Android device on a fixed place or to move around with the Android device.