android - Geocoder getFromLocation() not null but has size 0 always -
i trying retrieve location address using google api v2.
here do:
geocoder geocoder = new geocoder(this, locale.getdefault()); list<address> addresses = null; string addresstext = ""; try { while (addresses==null){ addresses = geocoder.getfromlocation(userlocation.latitude, userlocation.longitude, 1); } if (addresses != null && addresses.size() > 0) { address address = addresses.get(0); addresstext = string.format( "%s, %s, %s", address.getmaxaddresslineindex() > 0 ? address .getaddressline(0) : "", address .getlocality(), address.getcountryname()); } } catch (ioexception e) { e.printstacktrace(); }
i have read several posts , found getfromlocation() request not retrieve result. tried looping that.
this not crash addresstext "", ideas why? internet permissions have been given app. don't use gps.
userlocation not null, not problem, use add marker map , works fine. seems problem geocoder strictly.
you can address 2 method 1. using geocoder 2. using google api
you can solution link. has both solution. visit answer google api solution.
Comments
Post a Comment