Witam
Pisze prosty program wykorzystujący dane z GPS i wyświetlający je. Jednak mam pewien problem bo cały czas sygnalizuje mi jakis nieznany mi błąd.
Oto kod programu (część ta najważniejsza)
import javax.microedition.midlet.*;
import javax.microedition.location.*;
import javax.microedition.lcdui.*;
/**
* @author Sebastian
*/
public class GPS extends MIDlet {
private Criteria cr;
private LocationProvider provider;
private Display dp;
private Alert alert;
private Location location;
public GPS(){
// Criteria can be used to filter which GPS device to use.
Criteria criteria = new Criteria();
criteria.setCostAllowed(true);
criteria.setPreferredPowerConsumption(Criteria.NO_REQUIREMENT);
try{
// Get a location provider based on the aforementioned criteria.
LocationProvider provider = LocationProvider.getInstance(criteria);
}
catch(LocationException e){
System.out.println("Błąd");
}
try{
////////////////////////////////////////////////////////////////////////////////////////
// ponizej jest błąd
Location location = provider.getLocation(180);
//////////////////////////////////////////////////////////////////////////////////////////
}
catch(LocationException e)
{
System.out.println("Błąd");
}
// Get the coordinates of the current location.
Coordinates coordinates = location.getQualifiedCoordinates();
if (coordinates != null) {
// Get the latitude and longitude of the coordinates.
double latitude = coordinates.getLatitude();
double longitude = coordinates.getLongitude();
} else {
// You didn't get any coordinates.
}
Używam NetBeans IDE ale nie sądze, że gdybym wykorzystał inny program to błąd by zniknął