简体   繁体   中英

Android - Geocoder - getFromLocation - isPresent()

I'm trying to get the full address of my phone's location but there's no way to get it. I've seen that there are other questions regarding this problem on SO but I didn't find any solution.

I restarted the phone, I tried to use API 19 and API 20 and "don't know what else I've found on the net as a possible solution", then I connected my old phone and... it works!

So, the phone with android 4.2.2 works (means geocoder.isPresent() == true -> can find address via getFromLocation ), android 4.4.2 doesn't.

Can someone explain me why and if there's a way to fix it ? I'm doing an app that will be (hopefully) used by many phones so I'd like to know how to fix it as, location, is a really crucial part of the app.

Please don't suggest me to use Google's http://maps.googleapis.com , it's forbidden :

https://developers.google.com/maps/documentation/geocoding/

This service is generally designed for geocoding static (known in advance) addresses for placement of application content on a map

NOTE : I don't get any error or exceptions from geocoder, just a false from isPresent() and an empty address list from getFromLocation .

I've solved in a very simple way: displaying in the app a little map that displays the current location. This permits me to call the google map api and display the address (and makes the app even nicer). It's what WhatsApp does, indeed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM