Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过编程在blackberry上找到方向?_Blackberry_Gps - Fatal编程技术网

如何通过编程在blackberry上找到方向?

如何通过编程在blackberry上找到方向?,blackberry,gps,Blackberry,Gps,如何使用GPS以编程方式在黑莓手机上找到方向?GPS数据无法为您提供方向,它只提供位置信息。如果你有两个位置(比如一秒钟前的位置和现在的位置),大多数实现,包括黑莓,都会给你从一点到另一点的方位(方向) 安卓设备和IIRC的iphone3gs,带有数字磁罗盘,可以给你指引方向。我相信还没有任何黑莓手机配备罗盘。使用GPS,最低分辨率约为3米。如果您连续读取GPS读数,并在给定方向上寻找重大变化,它将为您提供旅行方向的粗略估计,从而确定此人可能面临的方向 这远不如有一个磁罗盘好,目前市场上没有一款

如何使用GPS以编程方式在黑莓手机上找到方向?

GPS数据无法为您提供方向,它只提供位置信息。如果你有两个位置(比如一秒钟前的位置和现在的位置),大多数实现,包括黑莓,都会给你从一点到另一点的方位(方向)


安卓设备和IIRC的iphone3gs,带有数字磁罗盘,可以给你指引方向。我相信还没有任何黑莓手机配备罗盘。

使用GPS,最低分辨率约为3米。如果您连续读取GPS读数,并在给定方向上寻找重大变化,它将为您提供旅行方向的粗略估计,从而确定此人可能面临的方向

这远不如有一个磁罗盘好,目前市场上没有一款黑莓(Blackberry?)有磁罗盘

有些GPS系统有两个GPS接收器,它们以已知方向并排放置。他们可以通过比较两个GPS读数来计算装置所面对的方向。他们称之为GPS罗盘。而且,在这一点上,它们太大了,不能放在手机里


您可以使用来查找GPS信息,包括航向良好的航向(getCourse方法)。它将为您提供一个指南针读数,0.00为北。

黑莓使用的java micro中的GPS API将为您提供手机的前进方向。以下是一个GPS类的片段,该类检索大部分基本GPS信息:

/**
 * This will start the GPS
 */
public GPS() {
    // Start getting GPS data
    if (currentLocation()) {
        // This is going to start to try and get me some data!
    }
}

private boolean currentLocation() {
    boolean retval = true;
    try {
        LocationProvider lp = LocationProvider.getInstance(null);
        if (lp != null) {
            lp.setLocationListener(new LocationListenerImpl(), interval, 1, 1);
        } else {
            // GPS is not supported, that sucks!
            // Here you may want to use UiApplication.getUiApplication() and post a Dialog box saying that it does not work
            retval = false;
        }
    } catch (LocationException e) {
        System.out.println("Error: " + e.toString());
    }

    return retval;
}

private class LocationListenerImpl implements LocationListener {
    public void locationUpdated(LocationProvider provider, Location location) {
        if (location.isValid()) {
            heading = location.getCourse();
            longitude = location.getQualifiedCoordinates().getLongitude();
            latitude = location.getQualifiedCoordinates().getLatitude();
            altitude = location.getQualifiedCoordinates().getAltitude();
            speed = location.getSpeed();

            // This is to get the Number of Satellites
            String NMEA_MIME = "application/X-jsr179-location-nmea";
            satCountStr = location.getExtraInfo("satellites");
            if (satCountStr == null) {
                satCountStr = location.getExtraInfo(NMEA_MIME);
            }

            // this is to get the accuracy of the GPS Cords
            QualifiedCoordinates qc = location.getQualifiedCoordinates();
            accuracy = qc.getHorizontalAccuracy();
        }
    }

    public void providerStateChanged(LocationProvider provider, int newState) {
        // no-op
    }
}

用户面对的方向或用户行驶的方向?它们是两个不同的概念。