Retrieve the speed of the BlackBerry device, in meters per second

  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.getSpeed() and save the value that the method returns to a float variable.
    float speed = mylocation.getSpeed();
    

Was this information helpful? Send us your comments.