개발 가이드

Local Navigation

코드 샘플: BlackBerry 단말기의 GPS 위치 검색

import javax.microedition.location.*;
public class handleGPS
{
    static GPSThread gpsThread;
    static double latitude;
    static double longitude;
    public handleGPS()
    {
        gpsThread = new GPSThread();
        gpsThread.start();
    }
    private static class GPSThread extends Thread
    {
        public void run()
        {
            Criteria myCriteria = new Criteria();
            myCriteria.setCostAllowed(false);
            try
            {
                LocationProvider myLocationProvider =
                    LocationProvider.getInstance(myCriteria);
                try
                {
                    Location myLocation = myLocationProvider.getLocation(300);
                    latitude  = myLocation.getQualifiedCoordinates().getLatitude();
                    longitude = myLocation.getQualifiedCoordinates().getLongitude();
                }
                catch ( InterruptedException iex )
                {
                    return;
                }
                catch ( LocationException lex )
                {
                    return;
                }
            }
            catch ( LocationException lex )
            {
                return;
            }
            return;
        }
    }
}

이 정보가 도움이 되었습니까? 의견을 보내 주십시오.