在BlackBerry上获取GPS位置

时间:2010-11-10 13:40:28

标签: blackberry

我无法使用此功能读取位置。当我尝试获取位置信息时,它总是返回高度0,经度0。

    void getirGps(){
        Criteria myCriteria = new Criteria();
        myCriteria.setCostAllowed(false);

        try
        {
            LocationProvider myLocationProvider =
                LocationProvider.getInstance(myCriteria);

            try
            {
                Location myLocation = myLocationProvider.getLocation(300);

                seTLatitude(myLocation.getQualifiedCoordinates().getLatitude());// sunlarıda bir public statıc dene..
                seTLongitude(myLocation.getQualifiedCoordinates().getLongitude());
                Dialog.alert("latitude = "+GPSThread.latitude +" longi"+GPSThread.longitude);
                velocity   = myLocation.getSpeed();
                heading    = myLocation.getCourse();
                timeStamp  = myLocation.getTimestamp();
                nmeaString = myLocation.getExtraInfo
                    ("application/X-jsr179-location-nmea");
            }
            catch ( InterruptedException iex )
            {
                Dialog.alert("InterruptedException");
                return;
            }
            catch ( LocationException lex )
            {
                Dialog.alert("LocationException lex");
                return;
            }
        }
        catch ( LocationException lex )
        {
            Dialog.alert("LocationException lex2");
            return;
        }

    }


public void doThis(){

    MapView mapView = new MapView();
    mapView.setLatitude( (int) Threads.latitude);//39.9208, Longitude = 32.8541 
    mapView.setLongitude((int) Threads.longitude);
    mapView.setZoom(10);
    MapsArguments mapsArgs = new MapsArguments(mapView);
    Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, mapsArgs);

    Dialog.alert("latitude = "+Threads.latitude +" longi"+Threads.longitude);

1 个答案:

答案 0 :(得分:0)

确保设备上已启用GPS functionality