在 BLACKbERRY 10 中获取设备位置
Getting Device Location in BLACKbERRY 10
>我正在 BlackBerry 10 中开发一个应用程序,我需要在纬度、经度中获取设备位置,然后想要获取地址。我已经浏览了黑莓文档示例应用程序,但它非常复杂。谁能告诉我我应该怎么做? 或者为我提供简单的代码,例如获取纬度和经度。
检查下面的代码。
void App::positionUpdated(QGeoPositionInfo geoPositionInfo) {
if (geoPositionInfo.isValid()) {
// We've got the position. No need to continue the listening.
locationDataSource->stopUpdates();
// Save the position information into a member variable
myPositionInfo = geoPositionInfo;
// Get the current location as latitude and longitude
QGeoCoordinate geoCoordinate = geoPositionInfo.coordinate();
qreal latitude = geoCoordinate.latitude();
qreal longitude = geoCoordinate.longitude();
qDebug()<< QString("Latitude: %1 Longitude: %2").arg(latitude).arg(longitude);
}
}
void App::startGPS() {
qDebug() << " << starting GPS >>";
// Obtain the location data source if it is not obtained already
if (!locationDataSource) {
locationDataSource = QGeoPositionInfoSource::createDefaultSource(this);
// Whenever the location data source signals that the current
// position is updated, the positionUpdated function is called
connect(locationDataSource, SIGNAL(positionUpdated(QGeoPositionInfo)),this, SLOT(positionUpdated(QGeoPositionInfo)));
// Start listening for position updates
locationDataSource->startUpdates();
}
}
只需在默认构造函数类中调用 startGPS() 方法即可。
有关更多信息,您可以转到此处。
相关文章:
- 使用Unreal C++获取VR耳机的世界位置/方向
- 无法获取webot::PositionSensor对象中位置传感器的值
- 如何获取矢量循环的整数位置
- 如何在不等待检索的情况下获取C++中的内存位置?
- 获取网格中心的屏幕位置
- C++ - 重置字符串流不会重置获取位置或清除标志吗?
- 创建一个类来访问和指定向量类型,并构建一个获取位置并为其分配区域的类
- SFML 鼠标获取位置无法正常工作
- 获取窗口中的鼠标位置
- 如何在读取时获取套接字流的位置
- JNI如何从CPP获取JAR位置
- wx工具栏:获取工具的位置和大小
- C 获取std :: out_of_range异常的位置
- ClangTool 如何获取变量声明中模板参数的位置?
- 如何获取设置位中的相对位置
- 如何从 stl 向量中最小元素的迭代器位置获取 int/size_t 值
- 在调用函数的任何位置获取文件名和函数名
- 将文件内容从特定位置获取到另一个特定位置
- OpenGL ES-从相机位置获取2D像素坐标
- 使用 EnvDTE 从 Visual Studio 中 c++ 头文件中的光标位置获取 CodeElement