Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android

Using 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

After 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.