1

Because I don't want to confuse, I will try to explain with the SDK example-code.

Everything works fine - except the "onMyLocationChange" Callback.

 - API 16 & 17 tested 
 - updated Play Services Rev.5 
 - Tested with ICS Tablet&Phone

I just added what is needed to receive location-updates:

UiSettingsDemoActivity implements OnMyLocationChangeListener

attached it to the map:

mMap.setOnMyLocationChangeListener(this);

and implemented the callback

@Override
public void onMyLocationChange(Location arg0) {
    ....
}

But this method is never triggered.

Release Notes from 26. Feb: https://groups.google.com/d/msg/google-maps-android-api-notify/va_IsjNu5-M/QPtoSn69UMgJ - So I thought this is working.

EDIT: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4644

everyman
  • 3,377
  • 1
  • 34
  • 33

2 Answers2

1

Have you added a LocationListener in your application?:

locationListener = new MyLocationListener();  
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);

MyLocationListener:

public class MyLocationListener implements LocationListener 
{
static final String TAG = MyLocationListener.class.getSimpleName();
@Override
public void onLocationChanged(Location location) {
     SGTasksListAppObj.getInstance().currentUserLocation = location;
     Log.d(TAG, "New location was set to currentUserLocation: "+location.toString());

}

@Override
public void onProviderDisabled(String provider) {
    // TODO Auto-generated method stub
}

@Override
public void onProviderEnabled(String provider) {
    // TODO Auto-generated method stub
}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
    // TODO Auto-generated method stub
}

}

Update:

Maybe you should try the:

map.setMyLocationEnabled(boolean boolean);

method, and check this link:

How to get My Location changed event with Google Maps android API v2?

Community
  • 1
  • 1
Emil Adz
  • 40,709
  • 36
  • 140
  • 187
  • [link](http://developer.android.com/reference/com/google/android/gms/maps/GoogleMap.OnMyLocationChangeListener.html) This is official since Rev.5 (26.02.2013) – everyman Apr 01 '13 at 23:53
  • strangely Eclipse doesn't recognize this method. I guess I need to updated my SDK. Well taking my words back regarding the "There is no...", but nevertheless you sill have to set a loicationListener in order to get notified on location changes. – Emil Adz Apr 01 '13 at 23:59
  • I am just updating my app to v2 - with v1 I had a custom LocationListener, but I thought that googles implementation works better. – everyman Apr 02 '13 at 00:00
  • Well I never used this method, So I have no idea how it works. – Emil Adz Apr 02 '13 at 00:00
  • hehe - Its the demo: mMap.setMyLocationEnabled(((CheckBox) v).isChecked()); So yes - its enabled – everyman Apr 02 '13 at 00:25
  • No actualy I didn't try the example, have you looked at this link: http://stackoverflow.com/questions/13742551/how-to-get-my-location-changed-event-with-google-maps-android-api-v2/14305851#14305851 – Emil Adz Apr 02 '13 at 00:27
0

How are you testing whether your location have changed? I would assume it would involve moving around or using dummy data and change the location manually. Does your gps need to be turned on?

  • Wifi/GPS and location-service is turned on - when I open the standard google Maps application, it works right away. I am also seeing that a locapi_rpc_glue process is flooding my logs. – everyman Apr 01 '13 at 23:57