everyman
everyman

Reputation: 3407

Android Google Maps v2 - OnMyLocationChangeListener - What does it need exactly?

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

Upvotes: 1

Views: 2058

Answers (2)

Emil Adz
Emil Adz

Reputation: 41119

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?

Upvotes: 1

ArgumentNullException
ArgumentNullException

Reputation: 71

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?

Upvotes: 0

Related Questions