首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何获取GPS数据?模拟器总是返回Tizen本机上禁用的运行时GPS。

如何获取GPS数据?模拟器总是返回Tizen本机上禁用的运行时GPS。
EN

Stack Overflow用户
提问于 2020-04-01 15:20:15
回答 1查看 201关注 0票数 0

我正在尝试访问Tizen本地应用程序的GPS数据。我打开了位置请求权限、特权,并授予了模拟器的权限。但是当我运行代码来访问位置信息时,它会得到零值。对于运行时位置信息,它将获得GPS禁用的等效返回。我需要访问模拟器上当前注入的位置。

检查GPS状态的示例代码:

代码语言:javascript
复制
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定位信息示例代码:

代码语言:javascript
复制
//init location manager with gps type.

location_manager_get_location(gps, &altitude, &latitude, &longitude, &climb,
        &direction, &speed, &level, &horizontal, &vertical, &timestamp);

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数据?

编辑解决方案:它必须检索有关位置管理器回调的信息。

EN

回答 1

Stack Overflow用户

发布于 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禁用状态下获得位置值。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60974379

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档