我正在尝试在Tizen本机应用程序上访问GPS数据。我已打开位置询问的权限,特权,并在模拟器上授予了权限。但是,当我运行代码以访问位置信息时,它将获得零值。对于运行时位置信息,它将获得GPS禁用等效回报。我需要访问模拟器上的当前注入位置。
用于检查GPS状态的示例代码:
retCheck = runtime_info_get_value_int(RUNTIME_INFO_KEY_GPS_STATUS,
&value_int);
if (retCheck != RUNTIME_INFO_ERROR_NONE) {
dlog_print(DLOG_ERROR, LOG_TAG, "runtime_info_get_value_int error: %d",
retCheck);
snprintf(chars, sizeof(chars),
"<br>runtime_info_get_value_int error: %d", retCheck);
strcat(str, chars);
return;
} else {
switch (value_int) {
case RUNTIME_INFO_GPS_STATUS_DISABLED:
dlog_print(DLOG_DEBUG, LOG_TAG, "GPS status: DISABLED.");
snprintf(chars, sizeof(chars), "<br>GPS status: DISABLED.");
strcat(str, chars);
break;
case RUNTIME_INFO_GPS_STATUS_SEARCHING:
dlog_print(DLOG_DEBUG, LOG_TAG, "GPS status: SEARCHING.");
snprintf(chars, sizeof(chars), "<br>GPS status: SEARCHING.");
strcat(str, chars);
break;
case RUNTIME_INFO_GPS_STATUS_CONNECTED:
dlog_print(DLOG_DEBUG, LOG_TAG, "GPS status: CONNECTED.");
snprintf(chars, sizeof(chars), "<br>GPS status: CONNECTED.");
strcat(str, chars);
break;
default:
dlog_print(DLOG_DEBUG, LOG_TAG, "GPS status: Unknown.");
snprintf(chars, sizeof(chars), "<br>GPS status: Unknown.");
strcat(str, chars);
break;
}
这里返回Serarching
。
gps位置信息的示例代码:
//init location manager with gps type.
location_manager_get_location(gps, &altitude, &latitude, &longitude, &climb,
&direction, &speed, &level, &horizontal, &vertical, ×tamp);
snprintf(chars, sizeof(chars),
"<br>In GPS: altitude %f, latitude %f, longitude %f, climb %f, direction %f, speed %f, horizontal %f, vertical %f",
altitude, latitude, longitude, climb, direction, speed, horizontal,
vertical);
这里所有值都是0。
如何获取GPS数据?
编辑解决方案:它必须检索有关位置管理器回调的信息。
请确保已启用GPS(在仿真器设置中手动启用->位置-> GPS)。
[本文可能会帮助您获取有关位置https://docs.tizen.org/application/native/guides/location-sensors/location的更多信息
也请检查此特权(http://tizen.org/privilege/location)。
启用GPS似乎存在问题,我们无法在GPS禁用状态下获取位置值。