0

I'm working on Android with the Google Places API. I'm having problems when running the PlaceDetectionApi's getCurrentPlace-method. The PlaceLikelihoodBuffer I get in the resultcallback of the method is empty, when I print the errorstatus in my logcat, it say's the errorcodenumber is 13 and in the logcat, I can also read the line "D/PlaceInferenceEngine: No place inference engine is running, returning null". I'm running this in an AVD on my emulator, unfortunately I can't test it on a real device in the moment. So, the question is: what is this place inference engine and how can I get it running on my AVD?

The relevant piece of code is this:

public void getCurrentPosition(int requestCode) {
        if(ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) !=
                PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION},
                    requestCode);
        } else {
            if(requestCode == PERMISSION_REQUEST_GET_CURRENT_POSITION) {
                PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi.getCurrentPlace(client, new PlaceFilter());
                result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
                    @Override
                    public void onResult(PlaceLikelihoodBuffer placeLikelihoods) {
                        System.out.println("inside callback...");
                        Status status = placeLikelihoods.getStatus();
                        System.out.println(status.isSuccess());
                        System.out.println(status.getStatusCode());
                        System.out.println(status.getStatusMessage());
                        for (PlaceLikelihood placeLikelihood : placeLikelihoods) {
                            Place place = placeLikelihood.getPlace();
                            System.out.println("possible place: " + place.getAddress());
                        }
                        placeLikelihoods.release();
                    }
                });
            }
         }
}

The result in my logcat is:

06-19 14:39:33.436 1865-2848/com.google.android.gms.persistent D/PlaceInferenceEngine: No place inference engine is running, returning null
06-19 14:39:33.437 1865-2284/com.google.android.gms.persistent W/Places: getLastLocation returned null. Falling back to location updates
06-19 14:39:33.621 1865-2148/com.google.android.gms.persistent W/GCoreFlp: No location to return for getLastLocation()
06-19 14:39:43.478 1865-2284/com.google.android.gms.persistent E/Places: Timed out waiting for a location for getCurrentPlace
06-19 14:39:43.500 2760-2760/com.example.kevin.mapproject I/System.out: inside callback...
06-19 14:39:43.500 2760-2760/com.example.kevin.mapproject I/System.out: false
06-19 14:39:43.500 2760-2760/com.example.kevin.mapproject I/System.out: 13
06-19 14:39:43.500 2760-2760/com.example.kevin.mapproject I/System.out: ERROR
Muhammad Waleed
  • 2,517
  • 4
  • 27
  • 75
Kevin
  • 72
  • 8
  • test on real device.... – Muhammad Waleed Jun 19 '16 at 17:04
  • ok, i'll try this as soon as possible. Nevertheless: is it even possible to retrieve the current position on avd? i just tried out LocationManager as an alternative, it also doesn't work – Kevin Jun 19 '16 at 18:14
  • As far I know, you can send lat-long to your emulator manually (not sure if there is any method to retrieve it automatically from your computer). In eclipse, start your emulator and then - Window > Open Perspective > DDMS > Emulator Control > type a lat-long > Send. – Sudip Podder Jun 19 '16 at 19:23
  • alright, thank you very much Sudip :) your suggestion was right, you have to provide mock data for the emulator, it is also written in the very end of this developer guide: https://developer.android.com/guide/topics/location/strategies.html – Kevin Jun 23 '16 at 13:15

0 Answers0