Retrieve the speed of the BlackBerry device, in meters per second
- Import the following classes:
- javax.microedition.location.LocationProvider
- javax.microedition.location.Location
- Create an instance of a LocationProvider.
LocationProvider provider = new LocationProvider();
- Invoke LocationProvider.getLocation() and assign the value that the method returns to a Location variable.
Location mylocation = provider.getLocation(-1);
- 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.