×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    32

    how to update gps

    how can i update this code so that it will display an update of the gps every 5 second


    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem ">
    /**
    * Returns an initiliazed instance of stringItem component.
    * @return the initialized component instance
    */
    public StringItem getStringItem() {
    if (stringItem == null) {
    // write pre-init user code here
    stringItem = new StringItem("Hello", "Hello, World!");

    locateme ();


    }
    return stringItem;
    }
    //</editor-fold>




    public void locateme () {

    try { Criteria cr = new Criteria();
    cr.setHorizontalAccuracy(500);
    LocationProvider lp = LocationProvider.getInstance(cr);
    Location l = lp.getLocation(60);
    Coordinates c = l.getQualifiedCoordinates();
    if (c != null) {

    String lat = c.convert(c.getLatitude(),c.DD_MM);
    if (c.getLatitude() > 0) {
    lat = "E " + lat;
    } else {
    lat = "W " + lat;
    }
    String lon = c.convert(c.getLongitude(),c.DD_MM);
    if (c.getLongitude() > 0) {
    lon = "N " + lon;
    } else {
    lon = "S " + lon;
    }
    stringItem = new StringItem("Hello", "Hello, World!");
    stringItem.setText("\nYour present location is \n" + lat + "\n" + lon);

    }
    } catch (Exception e) { //LocationException OR InterruptedException

    }}

  2. #2
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: how to update gps

    well you can poll the locationprovider every 5 seconds by using a timer
    Coordinates c = l.getQualifiedCoordinates();

    or even better you can use the LocationListener interface instead...
    I would advise you to have a good look at thew JSR-179 API Javadoc, it isn't a big API so it would be wise to fully understand it's funcitonality...

Similar Threads

  1. Replies: 9
    Last Post: 2010-03-12, 11:29
  2. GPS Listener - different behavior in emulator
    By neil.young in forum Symbian
    Replies: 4
    Last Post: 2009-12-15, 08:59
  3. Replies: 8
    Last Post: 2009-11-12, 10:28
  4. Update GPS repeatedly in background
    By NeoSpaghetti in forum Symbian
    Replies: 2
    Last Post: 2009-06-09, 23:07
  5. Replies: 0
    Last Post: 2008-05-12, 09:57

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×