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(strLoc开发者_JS百科ation, 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.
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.
String strAddress = "your address here/or location";
try{
List<Address> loc = geocoder.getFromLocationName(strAddress, 5);
}
catch(IOException e) {
Log.e("IOException", e.getMessage());
//Toaster on high-----------------//
Context context = getApplicationContext();
CharSequence text = "IOException: " + e.getMessage();
int dur = Toast.LENGTH_LONG;
Toast.makeText(context, text, dur).show();
精彩评论