Ich entwickle eine App mit Fused Location Provider. Ich habe einen Zweifel. Um den Standort in regelmäßigen Abständen zu erhalten, verwendet er requestLocationUpdates(). Aber von welcher Quelle wird es den Standort entweder von WIFI oder GPS oder Netzwerk bekommen. In meiner App wird der Standort nur in regelmäßigen Abständen angezeigt, wenn WLAN aktiviert ist. Wenn WiFi im OFF-Zustand ist, kann es den Ort nicht erreichen (es sollte Ort von einer anderen Quelle entweder von GPS oder Netzwerk bekommen. Aber es wird nie Ort bekommen. Oder ich muss Listener für GPS und Netzwerk schreiben). Ich weiß nicht, was das Problem ist. Kann mir jemand helfen.Fused Location Provider in Android
Und, ob es funktioniert, nur wenn alle Anbieter (Wifi, GPS, Netzwerk) verfügbar oder sonst.
public void checkPlay(){
int resp = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (resp == ConnectionResult.SUCCESS) {
locationClient = new LocationClient(this, this, this);
locationClient.connect();
} else {
Toast.makeText(this, "Google Play Service Error " + resp,
Toast.LENGTH_LONG).show();
}
}
public void onConnected(Bundle arg0) {
// TODO Auto-generated method stub
if (locationClient != null && locationClient.isConnected()) {
locationRequest = LocationRequest.create();
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setInterval(100);
locationClient.requestLocationUpdates(locationRequest, this);
}
}
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
try {
if (location != null) {
lat = location.getLatitude();
long = location.getLongitude();
}
} catch (Exception e) {
Log.d(Fots.TAG,
"GpsTrackService.mGpsLocationListener.onLocationChanged", e);
}
}
beziehen Sie sich das vielleicht hilfreich http://wptrafficanalyzer.in/blog/gps-and-google-map-in-android-applications-series/ – Aravin
Wie testen Sie für Standortaktualisierungen? –
twntee..Ich schreibe onLocationChanged() in einen Service. Wenn ich mich bei der App anmelde, wird der Dienst gestartet und der Dienst wird alle 1 Minute ausgeführt. Die Standortaktualisierung wird alle 5 Sekunden mit "locationRequest.setPriority (LocationRequest.PRIORITY_HIGH_ACCURACY)" durchgeführt. – Raja45