Hi everyone,
I'm developing gps application.This application find the users's gps coordinate.But i cant get the points because LocationProvider.getInstance get null.My code is below;
public class GpsLocation
extends Thread
{
private double lat; //lattitude
private double lon; //longtitude
private boolean gpsSupport; //gps destekleniyormu
/** Selected criteria */
private Criteria criteria = null;
/** Selected location provider */
private LocationProvider provider = null;
/**
*Constructor
*/
public GpsLocation()
{
//default values
lat=0;
lon=0;
gpsSupport=false;
//Detect Gps support or not support
if(isLocationApiSupported())
gpsSupport=true;
else
gpsSupport=false;
}
public void run()
{
if(gpsSupport)
checkLocation();
else
AnaMidlet.popUpUyariGoster("GPS desteklenmiyor");
}
public void checkLocation()
{
try
{
Criteria cr = new Criteria();
//cr.setHorizontalAccuracy(500);
cr.setPreferredPowerConsumption(Criteria.POWER_USAGE_HIGH);
provider = null;
provider = LocationProvider.getInstance(criteria);
if (provider != null)
{
Location lc=LocationProvider.getLastKnownLocation();
if(lc!=null && lc.isValid()){
QualifiedCoordinates coordinates=lc.getQualifiedCoordinates();
// Location provider found, send a selection event.
if (coordinates != null) {
// Get the latitude and longitude of the coordinates.
lat = coordinates.getLatitude();
lon = coordinates.getLongitude();
AnaMidlet.popUpUyariGoster("Lattitude:"+getLat()+ "Longtitude:"+getLon());
}
else {
AnaMidlet.popUpUyariGoster("Coordinates Null");
}
}
else{
AnaMidlet.popUpUyariGoster("Location Null");
}
}
else
{
AnaMidlet.popUpUyariGoster("Location Provider Null");
}
}
catch(Exception e){
AnaMidlet.popUpUyariGoster("GPS EXCEPTION:"+e.getMessage());
}
}
provider = LocationProvider.getInstance(criteria); this line get null during the application run on my mobile N79..ı know n79 has gps system..My platform is j2me polish and i use eclipse 3.4 ganymede and Sun Wtk 2.5.2..for Any solutions and advice thanks..Kamo![]()

Reply With Quote


