如果您检查link上的实现,则IOException是检查的异常,并从代码中抛出。 参考我从上面的链接更增加实现可以在注释中找到实施
public List<Address> getFromLocationName(String locationName, int maxResults) throws IOException {
if (locationName == null) {
throw new IllegalArgumentException("locationName == null");
}
try {
List<Address> results = new ArrayList<Address>();
String ex = mService.getFromLocationName(locationName,
0, 0, 0, 0, maxResults, mParams, results);
if (ex != null) {
throw new IOException(ex);
} else {
return results;
}
} catch (RemoteException e) {
Log.e(TAG, "getFromLocationName: got RemoteException", e);
return null;
}
}
NetworkOnMainThreadException是一个未经检查的异常,因为它从Java文档扩展RuntimeException的这个link可能会有帮助。 希望这回答你的问题。
如果'mGeo'是一个'Geocoder',那么你在自己的过程中并不是自己做网络I/O。 – CommonsWare