In this case I use GPS as a Provider, I try walking inside the building but seem like it doesn’t find the location. Yeah, it makes sense that in the building GPS not work. So, Why isProviderEnabled return true? Anyway, What is the way that i should implement “Searching for GPS signal”?
String context = Context.LOCATION_SERVICE;
locman = (LocationManager)getSystemService(context);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setPowerRequirement(Criteria.POWER_LOW);
String provider = locman.getBestProvider(criteria, true);
if (locman.isProviderEnabled( LocationManager.GPS_PROVIDER )) {
// Change from 'Searching for GPS signal to Use GPS'
txtGPS.setText("Use GPS");
}
locman.requestLocationUpdates(
provider,MIN_TIME, MIN_DISTANCE, locationListener);
isProviderEnabled()only looks if you have enabled GPS or not, it dosn’t take care if you see any satellites!If you like to check, if there are any satellites you have to use the
gpslistenerand this is how to use the gpslistner:To get this one working, you need to start a locationmanager which wants to use the gps, now your gpslistner can check if there are any satellites in view and writes a variable true or false. Afterwards you can check the Variabel. If its true (at least 4 Satellites in View) you can use
Criteria.ACCURACY_FINEelse you can useCriteria.ACCURACY_COARSE.Don’t forget to set the permission for both!Best Regards
safari