AndroidGpsLocationProviderpublic final class AndroidGpsLocationProvider extends Object implements android.location.LocationListenerGPS provider implementation for Android. |
Fields Summary |
---|
private static final String | TAGLogging tag | private android.location.LocationManager | locationManagerOur location manager instance. | private long | nativeObjectThe native object ID. |
Constructors Summary |
---|
public AndroidGpsLocationProvider(android.webkit.WebView webview, long object)
nativeObject = object;
locationManager = (LocationManager) webview.getContext().getSystemService(
Context.LOCATION_SERVICE);
if (locationManager == null) {
Log.e(TAG,
"AndroidGpsLocationProvider: could not get location manager.");
throw new NullPointerException(
"AndroidGpsLocationProvider: locationManager is null.");
}
// Register for location updates.
try {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
this);
} catch (IllegalArgumentException ex) {
Log.e(TAG,
"AndroidLocationGpsProvider: could not register for updates: " + ex);
throw ex;
} catch (SecurityException ex) {
Log.e(TAG,
"AndroidGpsLocationProvider: not allowed to register for update: "
+ ex);
throw ex;
}
|
Methods Summary |
---|
private native void | nativeLocationChanged(android.location.Location location, long object)The native method called when a new location is available.
| private native void | nativeProviderError(boolean isDisabled, long object)The native method called when there is a GPS provder error.
| public void | onLocationChanged(android.location.Location location)Called when the location has changed.
Log.i(TAG, "Location changed: " + location);
nativeLocationChanged(location, nativeObject);
| public void | onProviderDisabled(java.lang.String provider)Called when the provider is disabled.
Log.i(TAG, "Provider " + provider + " disabled.");
nativeProviderError(true, nativeObject);
| public void | onProviderEnabled(java.lang.String provider)Called when the provider is enabled.
Log.i(TAG, "Provider " + provider + " enabled.");
// No need to notify the native side. It's enough to start sending
// valid position fixes again.
| public void | onStatusChanged(java.lang.String provider, int status, android.os.Bundle extras)Called when the provider status changes.
Log.i(TAG, "Provider " + provider + " status changed to " + status);
if (status == LocationProvider.OUT_OF_SERVICE ||
status == LocationProvider.TEMPORARILY_UNAVAILABLE) {
nativeProviderError(false, nativeObject);
}
| public void | shutdown()Called when the provider is no longer needed.
locationManager.removeUpdates(this);
Log.i(TAG, "GPS provider closed.");
|
|