09-14-2011 03:24 AM - last edited on 09-14-2011 03:29 AM
Hi frnds,
I need to get the current GPS location through my java program. Im using the following code. This code is working for simulator. but not in device.. In my device GPS showing the proper location. But through this coding im not able to get. Please help me.. Its urgent. Thanks in advance
public class gps extends MainScreen {
static GPSThread gpsThread;
static double latitude;
static double longitude;
public gps() {
gpsThread = new GPSThread(); gpsThread.start();
}
private static class GPSThread extends Thread {
public void run() {
Criteria myCriteria = new Criteria();
myCriteria.setCostAllowed(false);
try{
LocationProvider myLocationProvider = LocationProvider.getInstance(myCriteria);
try {
Location myLocation = myLocationProvider.getLocation(300);
latitude = myLocation.getQualifiedCoordinates().getLatitude()
longitude = myLocation.getQualifiedCoordinates().getLongitude(
StringBuffer sb = new StringBuffer();
sb.append(latitude);
sb.append(":");
sb.append(longitude);
String msg = sb.toString();
showResults(msg);
}
catch ( InterruptedException iex )
{ return; }
catch ( LocationException lex ) { return; }
} catch ( LocationException lex ) { return; }
return;
}
}
private static void showResults(final String msg){
Application.getApplication().invokeLater(new Runnable() {
public void run() {
Dialog.alert(""+msg);
}
});
}
}
Solved! Go to Solution.
09-14-2011 03:28 AM
Program is not visible at my end.
09-14-2011 03:29 AM
Can you please check now
09-14-2011 04:05 AM
09-14-2011 04:43 AM
Hi swap_chau,
Thanks for your response.. i increased the time....but no luck...hepl me.
Thanks,
Karthika J
09-14-2011 05:07 AM
09-14-2011 05:27 AM
Hi swap_chau,
Thanks for your response.i checked the timeout.. i kept the timeout as 10 mins... i set the location mode as "GPSInfo.GPS_MODE_ASSIST"... but no luck..
Thanks,
Karthika J
09-14-2011 05:47 AM
09-14-2011 06:33 AM - last edited on 09-14-2011 06:33 AM
Thanks for your response...I changed as you said...Its working in simulator..not in device..i dont know why its not working in device...i checked device settings...its fine only..but
!!!!!!!!!!!!!!
Thanks,
Karthika J
09-14-2011 09:04 AM
Hi please help me regarding GPS
Thanks,
Karthika J