开发者

Get GPS location on BlackBerry

I can't read location with this function. When I try to get location information, it always returns altitude 0, longitude 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开发者_JAVA百科.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);


Make sure the GPS functionality is enabled on the device.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜