Retrieve the time that a BlackBerry device application retrieved GPS information

  1. Import the following classes:
    • javax.microedition.location.LocationProvider
    • javax.microedition.location.Location
  2. Create an instance of a LocationProvider.
    LocationProvider provider = new LocationProvider();
  3. Invoke LocationProvider.getLocation() and assign the value that the method returns to a Location variable.
    Location mylocation = provider.getLocation(-1);
    
  4. Invoke Location.getTimeStamp() and assign the value that the method returns to a long variable. The time is retrieved from the GPS receiver on the BlackBerry® device.
    long timestamp = myLocation.getTimeStamp();
    

Was this information helpful? Send us your comments.