System Information Retrieval for GPS and Data Roaming

Introduction

Retrieval of runtime information is an important feature while developing certain type of applications. This tip document will describe how to check GPS (enable/disable) and Data Roaming (enable/disable) information on Tizen devices.

Use Case: Applications such as navigation system and path finder need to know accurately the current position of device. These type of applications need access to GPS information and also the current state of GPS. In addition, applications using data connections need to know if roaming feature is enabled and the current state of roaming.

First Thing First:

Step 1: To check status of GPS and Data Roaming, the header below shoulde be added.

#include <runtime_info.h>

Getting Information:

Step 2:

For retrieving Data Roaming Information.

bool value_bool;
int ret;
ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED, &value_bool);

For retrieving GPS Information.

int value_int;
int ret;

ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_GPS_STATUS, &value_int);

Error Handling:

Step 3:

Code snippet for error handling while retrieving Data Roaming related information.

if (ret != RUNTIME_INFO_ERROR_NONE) {
        PRINT_MSG("runtime_info_get_value_bool error: %d", ret);
        dlog_print(DLOG_ERROR, LOG_TAG, "runtime_info_get_value_bool error: %d", ret);
        return;
    } else {
        dlog_print(DLOG_DEBUG, LOG_TAG, "DATA ROAMING: %s", value_bool ? "Enabled" : "Disabled");
        PRINT_MSG("DATA ROAMING: %s", value_bool ? "Enabled" : "Disabled");
    }

Code snippet for error handling while retrieving GPS related information.

if (ret != RUNTIME_INFO_ERROR_NONE) {
        PRINT_MSG("runtime_info_get_value_int error: %d", ret);
        dlog_print(DLOG_ERROR, LOG_TAG, "runtime_info_get_value_int error: %d", ret);
        return;
    } else {
        switch (value_int) {
        case RUNTIME_INFO_GPS_STATUS_DISABLED:
            dlog_print(DLOG_DEBUG, LOG_TAG, "GPS status: DISABLED.");
            PRINT_MSG("GPS status: DISABLED.");
            break;

        case RUNTIME_INFO_GPS_STATUS_SEARCHING:
            dlog_print(DLOG_DEBUG, LOG_TAG, "GPS status: SEARCHING.");
            PRINT_MSG("GPS status: SEARCHING.");
            break;

        case RUNTIME_INFO_GPS_STATUS_CONNECTED:
            dlog_print(DLOG_DEBUG, LOG_TAG, "GPS status: CONNECTED.");
            PRINT_MSG("GPS status: CONNECTED.");
            break;

        default:
            dlog_print(DLOG_DEBUG, LOG_TAG, "GPS status: Unknown.");
            PRINT_MSG("GPS status: Unknown.");
            break;
        }
    }

Tizen API for further references:

[1] https://developer.tizen.org/dev-guide/2.4/org.tizen.native.mobile.apireference/group__CAPI__SYSTEM__RUNTIME__INFO__MODULE.htm

A sample app is attached to show case  the feature of getting current state of GPS and Data Roaming. See below for a screenshot of this sample app.

File attachments: 
List
SDK Version Since: 
2.4 mobile/2.3.1 wearable