Android Maps & Reverse Geolocation

Need to get the street address from a lat/lng coord.

The code I have was working fine until a recent build, and it still works fine on IOS.

After getting the lat/lng from GPS, I’ve tried call the 'nearestAddress function using either:

myMap:nearestAddress( _S.lat, _S.lng, mapAddressHandler )

or

Runtime:addEventListener( “mapAddress”, mapAddressHandler )

neither of which work in Android.

Option works fine in IOS.

Can someone advise, as this is critical to my app, thanks

Do you have the internet permission set in your build.settings file??  It should look something like this:

settings = { orientation = { default = "portrait", supported = { "portrait", } }, androidPermissions = { "android.permission.INTERNET", }, }  

yes, as I say, it was working fine in an older build. Anyone got this to work in latest builds?

It works in 1016, but not 1076+

I’ve tested this on the latest build it works.  Perhaps you can share the piece of code you’re using so we can get to the bottom of this.

The only difference between those two versions of Corona that you’ve tested with is that we’ve removed all Android permissions that we used to impose on all Android builds.  We used to include Android permissions INTERNET, READ_PHONE_STATE, and ACCESS_NETWORK_STATE by default, and due to popular demand, we removed them.  Now, Corona developers have to opt-in to using these permissions.  So, odds are it is an INTERNET permission issue.

I recommend that you try building our sample app “Interface/MapView” as-is and running it on your Android device to verify that it works on your device.  Also, have a look at that sample project’s “build.settings” because it contains the permissions you need.

Thanks for your replies. I had already tested the MapView code and it didn’t work on my phone, a a Samsung S3 LTE, and I did ask a colleague to test it on his identical phone with the same problem.

Today, I installed the app on a different phone (an S2), and it worked fine, so it had to be something wrong with the my phone. After knocking off ‘allow mock locations’ and rebooting several times, it suddenly started working! Uninstalling and re-installing the app was not enough. It appears it needed a cold reboot.

Thanks again guys! Not sure if the ‘allow mock locations’ was stopping the address finder working, but its worth checking if anybody else runs into the same problem.

Oh… interesting.  Thanks for posting that.  I’m sure that’ll help others who have ran into the same issue you have.

And I’m glad you’ve finally got it working.

Do you have the internet permission set in your build.settings file??  It should look something like this:

settings = { orientation = { default = "portrait", supported = { "portrait", } }, androidPermissions = { "android.permission.INTERNET", }, }  

yes, as I say, it was working fine in an older build. Anyone got this to work in latest builds?

It works in 1016, but not 1076+

I’ve tested this on the latest build it works.  Perhaps you can share the piece of code you’re using so we can get to the bottom of this.

The only difference between those two versions of Corona that you’ve tested with is that we’ve removed all Android permissions that we used to impose on all Android builds.  We used to include Android permissions INTERNET, READ_PHONE_STATE, and ACCESS_NETWORK_STATE by default, and due to popular demand, we removed them.  Now, Corona developers have to opt-in to using these permissions.  So, odds are it is an INTERNET permission issue.

I recommend that you try building our sample app “Interface/MapView” as-is and running it on your Android device to verify that it works on your device.  Also, have a look at that sample project’s “build.settings” because it contains the permissions you need.

Thanks for your replies. I had already tested the MapView code and it didn’t work on my phone, a a Samsung S3 LTE, and I did ask a colleague to test it on his identical phone with the same problem.

Today, I installed the app on a different phone (an S2), and it worked fine, so it had to be something wrong with the my phone. After knocking off ‘allow mock locations’ and rebooting several times, it suddenly started working! Uninstalling and re-installing the app was not enough. It appears it needed a cold reboot.

Thanks again guys! Not sure if the ‘allow mock locations’ was stopping the address finder working, but its worth checking if anybody else runs into the same problem.

Oh… interesting.  Thanks for posting that.  I’m sure that’ll help others who have ran into the same issue you have.

And I’m glad you’ve finally got it working.

Thank you admin20 for documenting this!  I’ve spent days trying to get my app to work, thinking I was doing something wrong.  I couldn’t get Corona’s MapView app to work either - same issue, reverse geocoding was fine under iOS, but not working on an Android device.  Turning “mock locations” off and rebooting my Android phone solved the issue!  I wish I had found your post earlier…  or perhaps Corona can add this bit of info to their documentation or to the MapView code!  Cheers!

Thank you admin20 for documenting this!  I’ve spent days trying to get my app to work, thinking I was doing something wrong.  I couldn’t get Corona’s MapView app to work either - same issue, reverse geocoding was fine under iOS, but not working on an Android device.  Turning “mock locations” off and rebooting my Android phone solved the issue!  I wish I had found your post earlier…  or perhaps Corona can add this bit of info to their documentation or to the MapView code!  Cheers!