Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialEnrique Gonzalez
3,490 PointsUsing Location Services on an Android emulator with Google Play Services
I've followed the tutorial: The Beginner’s Guide to Location in Android http://blog.teamtreehouse.com/beginners-guide-location-android
Everything seems setup properly. I am running the app on a Nexus 5 API 21 emulator with Google Play Services from the SDK Extras, and location services are turned on. The problem is I can't get a response with location information from the emulator.
In my onConnected method (see below), location is null, which I expected, and LocationServices.FusedLocationApi.requestLocationUpdates(. . .) executes. I don't receive any errors, but for some reason the onLocationChanged method is never called.
public void onConnected(Bundle bundle) {
Location location = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
if (location == null) { LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
}
else {
handleNewLocation(location);
};
}
I've used telnet to geo fix coordinates, but it hasn't helped. I suspect the issue is with the emulator configuration. To test it I've run the official Google Maps application on it and keep receiving the Toast message: " Waiting for location. . ."
I've exhausted my troubleshooting avenues and would appreciate any insights on how to get the tutorial application to work on an emulator.
Thanks,
Enrique
1 Answer
Enrique Gonzalez
3,490 PointsAfter another 5 or 6 hours of troubleshooting, I uninstalled all of my emulators and reinstalled them. This seems to have taken care of the issue. Please disregard this question.