This is a documentation provided by Google demonstrating how to make your app location aware. In addition, you can refer to the code on github here regarding GoogleSamples with android play location and in this specific one regarding location updates.
Thanks
Eva
Hanna Raczek
Hello. Thank you so much in advance for your help.
I'm attempting to put some points of interest at specific locations around my campus, and I'm floundering around a bit trying to figure out how to get the Google API to work and to get setLocation to fire properly. This is my first foray into app development (it's my capstone), as well as using location services and Wikitude, not to mention Android, in general, so I apologize if my code seems to be integrating several different methods of doing this. I have a hunch this is probably part of my problem. I am developing an Android app in Android Studio using the the Wikitude Javascript API.
THE PROBLEM
When I open my app to test, the Wikitude AR view camera displays fine, though there is a notification at the bottom that tells me it's trying to find my location.
WHAT I'VE DONE
To implement the Google API, I've been following tutorials and documentation online. I've gotten the key and gotten the certificate and registered my app with it and did all that, I've changed the correct files, and followed tutorials I believe to the letter. Location services are enabled for my app; I checked in the App Manager on my phone and saw that fine and course locations were enabled, as well as in the Manifest in my project.
When I run my app, there is an error in the logcat that says
beginFailureResolution for ConnectionResult{statusCode=SIGN_IN_FAILED, resolution=null, message=null}
even though I'm signed into Google on the phone. Maybe I don't fully understand what exactly I'm needing to be signed into; my initial assumption was to my google account, which I'm assuming extends to being signed into Google Play services. Is that right?
I had put in alerts in the POI Javascript file in the onLocationChanged function (which, from what I understand, is fired when I call myArchitectView.setLocation(long, lat, 5.0), and there was nothing, even when I sent hard-coded values to setLocation.
I tried calling setLocation in the onCreate method just to see, both before and after the architectView.onCreate(), but it made my app crash both times.
I've edited nothing in the original Javascript, and it is correctly being referenced in the index.html, which is from the first POI example project.
My plan all along has been to use the Google API to fetch my current latitude and longitude, and then use those to send to setLocation(). Is this correct?
This is what I thought of off the top of my head when it comes to what I've done to figure it out.
MY CODE
VIEWARACTIVITY.JAVA
ANDROID MANIFEST
POIATLOCATION.JS