Get GPS location on BlackBerry

本小妞迷上赌 提交于 2019-12-08 13:04:26

问题


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.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:


Make sure the GPS functionality is enabled on the device.



来源:https://stackoverflow.com/questions/4145044/get-gps-location-on-blackberry

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!