我正在尝试访问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数据?
编辑解决方案:它必须检索有关位置管理器回调的信息。
发布于 2020-04-02 12:29:45
确保您的GPS已启用(在模拟器设置中手动启用->Location->GPS)。
也许本文将帮助您了解更多关于location https://docs.tizen.org/application/native/guides/location-sensors/location的信息。
也检查此特权(http://tizen.org/privilege/location)。
在启用GPS方面似乎存在问题,我们无法在GPS禁用状态下获得位置值。
https://stackoverflow.com/questions/60974379
复制相似问题