地理编码 IOException 尝试搜索最近的医院
我正在尝试将医院搜索合并到我的应用程序中。它应该根据您的位置提供最近的 5 家医院。
我收到一个 IOException List geocodeResults= coder.getFromLocationName(strLocation, 5);在 Eclipse 中使用 coder.getFromLocationName(strLocation, 5);下划线是问题所在。
我还设置了位置粗略和精细以及互联网的权限,但我仍然收到此错误。
我还想获取这 5 个结果并列出医院名称、地址和距离。
我对 Android 编码还是新手。通过搜索这个网站,我发现了很多很棒且有用的帮助,所以这就是我要问的地方。
或者我希望我的应用程序将字符串“hospital”发送到谷歌地图,并让谷歌地图应用程序显示结果。我不在乎哪个。
提前感谢所有帮助
说实话,我并不完全理解上面列出的代码,我理解一些但不是全部。我确实知道这是帮助我实现目标的必要条件。
I am trying to incorporate and hospital search in my app. It is supposed to give the closest 5 hospitals based upon your location.
I am getting an IOException with List geocodeResults= coder.getFromLocationName(strLocation, 5); in Eclipse with coder.getFromLocationName(strLocation, 5); underlined being the issue.
I have also set the permissions for location coarse and fine as well as internet and still I am getting this error.
I would also like to take these 5 results and list them with the hospital name, address and miles away.
I am still new at coding for the android. I have come across a lot of great and useful help by searching this site, so here is where I am asking.
Either this or I want my app to send the string "hospital" to google maps and let google maps app display the results. I don't care which.
Thanx in advance for all the help
To be honest I do not completely understand the code I listed above, I understand some but not all. I do know it is a necessity to help me accomplish my goal.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在模拟器中使用地理编码器,您将遇到一些 IO 异常。实际上,Geocoder 并不是最可靠的服务,并且经常发出“服务不可用”IO 异常。我们中的一些人一直在地理编码器调用中循环,直到它返回干净为止,而其他人则尝试了其他措施。
我认为 2.3 及更高版本中的模拟器在这方面有一个错误项目,而在 2.2 以下版本中,它的工作相当零散。
这段代码将把实际的异常输出到 toast 消息中,并记录该异常。
If your'e using Geocoder in the Emulator you will have some IO Exceptions. Actually Geocoder is not the most reliable service and frequently issues a "Service Unavailable" IO Exception. There have been some of us that have looped at the Geocoder call until it comes back clean and others who have tried other measures.
I think the emulator in 2.3 and above has a bug item on this and in 2.2 below it works rather sporadically.
This bit of code will output the actual exception to a toast message and will logcat the exception as well.