android - Reverse GeoCoordinate Class gives Location Not found error -


i m using google reverse geocoding api in app, m succussfully able get coordinate using google geolocation api. m trying location name reverse geocoding api , returns location not found error

here code:

  geocoder geocoder= new geocoder(mainactivity.this, locale.english);            if(geocoder.ispresent()){            list<address> list;  	try {  			list = geocoder.getfromlocation(37.42279, -122.08506,1);  			 address address = list.get(0);  			 log.d("this working","thsi sis working");    	         stringbuffer str = new stringbuffer();  	         str.append("name: " + address.getlocality() + "\n");  	         str.append("sub-admin ares: " + address.getsubadminarea() + "\n");  	         str.append("admin area: " + address.getadminarea() + "\n");  	         str.append("country: " + address.getcountryname() + "\n");  	         str.append("country code: " + address.getcountrycode() + "\n");;    	         string straddress = str.tostring();  	         jsondatas.settext(straddress);  	          log.d("address", straddress);  		}       catch (ioexception e) {  			// todo auto-generated catch block  			e.printstacktrace();  		}

i have several question

  1. how google know app requested api , how google determine of quota app. in google api developer console, google gave quota app api
  2. why m getting location not found error searching on google map location showing
  3. do need add google geocoder api key app - right m geolocation api key using retrieve coordinates

please correct me if m wrong, please give suggestion code work fine

thanks

make sure have latest google play library in project. using code , working me.

 private class reversegeocodingtask extends asynctask<latlng, void, string> {         context mcontext;          public reversegeocodingtask(context context) {             super();             mcontext = context;         }          // finding address using reverse geocoding         @override         protected string doinbackground(latlng... params) {             geocoder geocoder = new geocoder(mcontext);             double latitude = params[0].latitude;             double longitude = params[0].longitude;             list<address> addresses = null;             string addresstext = "";              try {                  addresses = geocoder.getfromlocation(latitude, longitude, 1);                  thread.sleep(500);                  if (addresses != null && addresses.size() > 0) {                      address address = addresses.get(0);                      addresstext = string.format(                             "%s",                             address.getmaxaddresslineindex() > 0 ? address                                     .getaddressline(1) : "", "", "");                 }             } catch (ioexception e) {                 e.printstacktrace();              } catch (interruptedexception e) {                 e.printstacktrace();             }              return addresstext;         }          @override         protected void onpostexecute(string addresstext) {         } } 

where latlng latitude , longitute, check this doc.

and use write down new reversegeocodingtask(this).execute(latlng); want data.

make sure adding permission manifest file.

 <uses-permission android:name="android.permission.access_fine_location" />     <uses-permission android:name="android.permission.internet" /> 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -