summaryrefslogtreecommitdiffstats
path: root/location/java
diff options
context:
space:
mode:
authorMark Vandevoorde <mtv@google.com>2010-05-21 15:43:26 -0700
committerMark Vandevoorde <mtv@google.com>2010-05-21 15:43:26 -0700
commit01ac80b715881db22bde8b31633dd8a4dc375389 (patch)
tree2a49fc9e6ff824f729f64bdacb3b48835d99e367 /location/java
parent11c6847d5960edeb0f15d0fd34045c89bd302d41 (diff)
downloadframeworks_base-01ac80b715881db22bde8b31633dd8a4dc375389.zip
frameworks_base-01ac80b715881db22bde8b31633dd8a4dc375389.tar.gz
frameworks_base-01ac80b715881db22bde8b31633dd8a4dc375389.tar.bz2
Add Geocorder.isImplemented()
The Geocorder interface is not part of the Android core. It requires a backend service which may or may not be available on a device. The new isImplemented static method allows apps to discover whether the Geocorder is in fact available on the device. Change-Id: I2b5cf7bcc9cce4766bcbb156e91edf34b01f9296
Diffstat (limited to 'location/java')
-rw-r--r--location/java/android/location/Geocoder.java21
-rw-r--r--location/java/android/location/ILocationManager.aidl1
2 files changed, 21 insertions, 1 deletions
diff --git a/location/java/android/location/Geocoder.java b/location/java/android/location/Geocoder.java
index c325b1b..546bb9d 100644
--- a/location/java/android/location/Geocoder.java
+++ b/location/java/android/location/Geocoder.java
@@ -40,7 +40,9 @@ import java.util.List;
*
* The Geocoder class requires a backend service that is not included in
* the core android framework. The Geocoder query methods will return an
- * empty list if there no backend service in the platform.
+ * empty list if there no backend service in the platform. Use the
+ * isImplemented() method to determine whether a Geocoder implementation
+ * exists.
*/
public final class Geocoder {
private static final String TAG = "Geocoder";
@@ -49,6 +51,23 @@ public final class Geocoder {
private ILocationManager mService;
/**
+ * Returns true if the Geocoder methods getFromLocation and
+ * getFromLocationName are implemented. Lack of network
+ * connectivity may still cause these methods to return null or
+ * empty lists.
+ */
+ public static Boolean isImplemented() {
+ IBinder b = ServiceManager.getService(Context.LOCATION_SERVICE);
+ ILocationManager lm = ILocationManager.Stub.asInterface(b);
+ try {
+ return lm.geocoderIsImplemented();
+ } catch (RemoteException e) {
+ Log.e(TAG, "isImplemented: got RemoteException", e);
+ return false;
+ }
+ }
+
+ /**
* Constructs a Geocoder whose responses will be localized for the
* given Locale.
*
diff --git a/location/java/android/location/ILocationManager.aidl b/location/java/android/location/ILocationManager.aidl
index a86f329..32d4b27 100644
--- a/location/java/android/location/ILocationManager.aidl
+++ b/location/java/android/location/ILocationManager.aidl
@@ -67,6 +67,7 @@ interface ILocationManager
// it need not be shared with other providers.
void reportLocation(in Location location, boolean passive);
+ boolean geocoderIsImplemented();
String getFromLocation(double latitude, double longitude, int maxResults,
in GeocoderParams params, out List<Address> addrs);
String getFromLocationName(String locationName,