I'm trying to geocode a lat/long coordinate using the android.location.Geocoder
on a HMS (Huawei Mobile Services) device, but I keep getting an empty list as the result.
val result = geoCoder.getFromLocation(latitude, longitude, MAX_RESULTS) // [] on HMS
To verify that this in fact should work I checked Geocoder.isPresent()
which returns true
.
Looking at the LogCat output I can see the following lines which suggest that I am missing some API key or didn't configure something correctly...
XX/? I/HwGeoCoderProvider: [I/HwLocation/HwGeoCoderProvider 1877:388 HwGeoCoderProvider.java:136] onGetFromLocation: start to GetFromLocation
XX/? D/HwGeoCoderProvider: [D/HwLocation/HwGeoCoderProvider 1877:388 HwGeoCoderProvider.java:434] exceed max requesting limit
XX/? D/HwGeoCoderProvider: [D/HwLocation/HwGeoCoderProvider 1877:388 HwGeoCoderProvider.java:162] exceed max requesting limit
XX/? I/HwGeoCoderProvider: [I/HwLocation/HwGeoCoderProvider 1877:388 HwGeoCoderProvider.java:455] {callTime=..., service=hwLocation, rom_type=1001, transId={{some uuid}}, package=com.android.phone, apiName=GeoCode_getFromLocation, costTime=1, result=10400}
I tried this on a P40 Pro, which has the latest HMS Core version (5.0.0.304) installed. I have received a few results before, so it definitely does work, but then it apparently hits this limit and stops working.
How can I geocode a lat/long using android.location.Geocoder
on a HMS device? What configuration / setup is necessary to avoid hitting this limit?
I've seen workarounds mentioned to use the location/site kit instead, but I'd prefer to use the "vanilla" Android API if possible.