Giriş
Şu satırı dahil ederiz.
Telefonları, GPS cihazlarına göre çok daha hızlı çalışıyor. Sebebi şöyle
constructor
Şöyle yaparız.
GPS, Network Provider'larından birisi etkinse bu metod çağrılabilir. Şöyle yaparız.
İmzası şöyle
Şöyle yaparız.
Şöyle yaparız.
Şöyle yaparız.
Şu satırı dahil ederiz.
import android.location.LocationManager;
GPS Bulmaz HızıTelefonları, GPS cihazlarına göre çok daha hızlı çalışıyor. Sebebi şöyle
The cell phone operating system downloads the GPS almanac data (satellite ephemeris and status information) over the internet via the cell network and loads it into the GPS module much faster than the it would take to download that from the GPS satellites directly at 50 bps (yes, that's 50 bits per second, GPS is rather old tech), significantly expediting the time to first fix. It also likely has a very accurate initial time reference from the cell modem (the cell towers are usually time synced via GPS) as well as possibly a coarse location estimate from the cell modem. All of this combined drastically reduces the amount of searching that the receiver has to do - it knows what satellites it should be able to see, so it only looks for those, and it doesn't need to wait around to for the satellites to transmit the entire message.Bu yönteme Assisted GPS deniliyor. Açıklaması şöyle
Cell phones use Assisted GPS, where cellular data is used to speed up obtaining a GPS fix.Almanac anladığım kadarıyla uydunun kaba yörünge bilgisi, ephemeris ise düzeltilmiş hassas yörünge bilgisi anlamına geliyor.
constructor
Şöyle yaparız.
LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE);
getLastKnownLocation metoduGPS, Network Provider'larından birisi etkinse bu metod çağrılabilir. Şöyle yaparız.
Location location = lm.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER)
GPS etkinse şöyle yaparız.Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
Şebeke etkinse şöyle yaparız.Location location = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
Sonuç null gelebilir. Kontrol etmek gerekir.if (location != null) {
double latitude = location.getLatitude();
double longitude = location.getLongitude();
}
getProviders metoduİmzası şöyle
LocationManager.getProviders (boolean enabledOnly)
GPS_PROVIDER AlanıŞöyle yaparız.
String gpsProvider = LocationManager.GPS_PROVIDER;
isProviderEnabled
İmzası şöyleLocationManager.isProviderEnabled (String provider)
GPS'in etkin olup olmadığını almak için şöyle yaparız.if (!lm.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
toast("GPS Not Eabled")
}
Şebekenin etkin olup olmadığını anlamak için şöyle yaparız.if (!lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { ...
}
NETWORK_PROVIDER AlanıŞöyle yaparız.
String networkProvider = LocationManager.NETWORK_PROVIDER;
requestLocationUpdates metodu
Bir LocationListener ile güncellemeler alınmaya başlanır. Şöyle yaparız. En az 2 saniye de bir ve konumda en az 10 metre değişiklik varsa güncelleme isteriz.lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 10, listener);
Şöyle yaparız.lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,listener);
minTime olarak 0, minDistance olarak 0 vererek şöyle yaparız.lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, listener);
removeUpdates metoduŞöyle yaparız.
lm.removeUpdates(listener);
Hiç yorum yok:
Yorum Gönder