【发布时间】:2012-09-14 03:44:50
【问题描述】:
我在模拟器和手机(Android 4.1 的 Nexus S)上都使用 Geocoder.getLocationFromName() 方法,但出现以下异常:
java.io.IOException: Service not Available
在模拟器 (example) 上出现了很多关于此的问题,其中大多数都说是特定版本的模拟器有问题。但是,异常出现在我的 AVD(2.3 和 4.1)和手机上。
我的手机和 AVD 都有互联网连接。我的 API 版本是 16(android 4.1),但我也尝试过使用旧版本。两种 AVD 都包含 Google API。
有什么想法吗?
这是相关代码sn -p:
Geocoder myGeocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
List<Address> newAddresses = myGeocoder.getFromLocationName(arg0.toString(), 10);
这是我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.asdasd" android:versionCode="6" android:versionName="1.3.1">
<uses-sdk android:minSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application android:icon="@drawable/ic_launcher_asdasd"
android:label="@string/app_name">
<activity android:name=".AsdasdActivity" android:label="@string/app_name"
android:screenOrientation="portrait" android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation" />
</application>
</manifest>
【问题讨论】:
-
仅供参考,也可能与此问题有关:code.google.com/p/android/issues/detail?id=38009 重启设备似乎可以解决此问题。
-
无论我重启了多少次,对我来说它什么也没做。
标签: android geolocation geocoding