09-28-2012 01:27 AM
I developed a web service and I want to get a lat long using wifi.
I using that lat long to pass it value to php side where I want to take a location my php code is ready
I want to get a lat long on blackberry
Can any one give the code for getting lat long suing wifi or GPRS.
Thanks In Advance
Solved! Go to Solution.
09-28-2012 03:20 AM
Try this code:
public class LocHandler extends Thread{
private BlackBerryCriteria blackBerryCriteria = null;
private BlackBerryLocation blackBerryLocation = null;
private BlackBerryLocationProvider blackBerryLocationProvider = null;
double lat = 0.0;
double lng = 0.0;
public void run(){
blackBerryCriteria = new BlackBerryCriteria();
if(GPSInfo.isGPSModeAvailable(GPSInfo.GPS_MODE_CEL
{
blackBerryCriteria.setMode(GPSInfo.GPS_MODE_CELLSI
}
else if(GPSInfo.isGPSModeAvailable(GPSInfo.GPS_MODE_ASS
{
blackBerryCriteria.setMode(GPSInfo.GPS_MODE_ASSIST
}
else if(GPSInfo.isGPSModeAvailable(GPSInfo.GPS_MODE_AUT
{
blackBerryCriteria.setMode(GPSInfo.GPS_MODE_AUTONO
}
else
{
blackBerryCriteria.setCostAllowed(true);
blackBerryCriteria.setPreferredPowerConsumption(Cr
}
try {
blackBerryLocationProvider = (BlackBerryLocationProvider) BlackBerryLocationProvider.getInstance(blackBerryC
blackBerryLocation = (BlackBerryLocation) blackBerryLocationProvider.getLocation(60);
QualifiedCoordinates qualifiedCoordinates = blackBerryLocation.getQualifiedCoordinates();
lat = qualifiedCoordinates.getLatitude();
lng = qualifiedCoordinates.getLongitude();
System.out.println("Latitude :"+lat);
System.out.println("Longitude :"+lng);
}
catch(Exception e)
{
System.out.println("Error in location :"+e.toString());
System.out.println("Error in location :"+e.getMessage());
}
}
}
09-28-2012 06:57 AM
There is information regarding finding location using WiFi in this thread:
In case you have not already seen it:
http://supportforums.blackberry.com/t5/Java-Develo