Geocoder.getFromLocationName does not work for intersection address -


i trying use geocoder class in app , found geocoder.getfromlocationname returns null if address intersection of 2 streets. ex. "quail ave , dunford way, sunnyvale, ca 94087" . however, method works perfect other type address. during debug session, see address parameter passed , reflects correctly, "geocodematches" returns size(0) zero. appreciate help!!

public static list<address> getgeocode(@nonnull context context, @nonnull string address){     try {         geocodematches = new geocoder(context).getfromlocationname(address, 1);          if (!geocodematches.isempty())         {             return geocodematches;         }      } catch (ioexception e) {         log.e("error", "error retrieve geocode" + e);         e.printstacktrace();     }     return geocodematches; } 

geocoder working on networklocationservice. in cases, networklocationservice stopped working due reason. don't know exact reason. can address google api in case. hope below code you!

public static string getlocationaddressfromlatlong(context context, double latitude, double longitude) {     string finaladdress = "";     geocoder geocoder;     list<address> addresses = null;     geocoder = new geocoder(context.getapplicationcontext(), locale.getdefault());     try {         addresses = geocoder.getfromlocation(latitude, longitude, 1);     } catch (ioexception e) {         e.printstacktrace();     }     if (addresses != null && addresses.size() > 0) {         finaladdress = addresses.get(0).getaddressline(0) + ", " + addresses.get(0).getaddressline(1);     } else {         //get address google api         try {             jsonobject jsonobj = getjsonfromurl("http://maps.googleapis.com/maps/api/geocode/json?latlng=" + latitude + ","                     + longitude + "&sensor=true");             string status = jsonobj.getstring("status");             if (status.equalsignorecase("ok")) {                 jsonarray results = jsonobj.getjsonarray("results");                 jsonobject location = results.getjsonobject(0);                 finaladdress = location.getstring("formatted_address");             }          } catch (exception e) {             e.printstacktrace();         }     }     return finaladdress; } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -