Geocoder.isPresent() undefined for the type Geocod

2019-05-14 22:34发布

问题:

My Android and Java skills aren't so hot...

In the developer.android.com page for Geocoder, it says :

The Geocoder query methods will return an empty list if there no backend service in the platform. Use the isPresent() method to determine whether a Geocoder implementation exists.

However, when I try to call, for example :

if (Geocoder.isPresent()) {...

Eclipse tells me

The method isPresent() is undefined for the type Geocoder

How can I "use the isPresent() method"?

回答1:

public static boolean isPresent () method only available from API level 9, It means you should use Android 2.3 or latter version for that. Make sure you are using that. Then check Eclipse project configuration for Android SDK.

Reference: http://developer.android.com/reference/android/location/Geocoder.html