I'm using the MvvmCross Location plugin. On some devices, the MvxGeoLocation success fires, on others it never does. I have seen other similar questions with answers (MVVMCross IMvxGeoLocationWatcher Success Action never fires on Android). However, this is not working on all devices (rebooting), so the solution is not valid. The device I'm testing on right now is on Android V 4.0.3, HTC Vivid. The client is reporting the same issue on their devices. Below is my LocationService code, the OnLocation method is never firing on these devices.
public class LocationService : ILocationService
{
private readonly IMvxGeoLocationWatcher _locationWatcher;
private readonly IMvxMessenger _messenger;
public double Latitude { get; set; }
public double Longitude { get; set; }
public bool HasLocation()
{
return (Latitude != 0.0 && Longitude != 0.0);
}
public LocationService(IMvxGeoLocationWatcher locationWatcher, IMvxMessenger messenger)
{
_locationWatcher = locationWatcher;
_messenger = messenger;
_locationWatcher.Start(new MvxGeoLocationOptions(){ EnableHighAccuracy = true}, OnLocation, OnError);
}
private void OnError(MvxLocationError error)
{
_messenger.Publish(new GpsUnavailableMessage(this));
}
private void OnLocation(MvxGeoLocation location)
{
Latitude = location.Coordinates.Latitude;
Longitude = location.Coordinates.Longitude;
var message = new LocationMessage(this, location.Coordinates.Latitude, location.Coordinates.Longitude);
_messenger.Publish(message);
}
}
Here are the messages showing in LogCat, does this look like I'm getting a GPS location?
07-31 11:54:59.883: V/GpsLocationProvider(246): SV count: 9 ephemerisMask: 93d5 almanacMask: 93d5
07-31 11:54:59.883: V/GpsLocationProvider(246): sv: 1 snr: 0.0 elev: 7.0 azimuth: 146.0 E A
07-31 11:54:59.883: V/GpsLocationProvider(246): sv: 3 snr: 0.0 elev: 33.0 azimuth: 49.0 E A
07-31 11:54:59.883: V/GpsLocationProvider(246): sv: 5 snr: 0.0 elev: 0.0 azimuth: 0.0 E A
07-31 11:54:59.883: V/GpsLocationProvider(246): sv: 7 snr: 0.0 elev: 74.0 azimuth: 351.0 E A
07-31 11:54:59.883: V/GpsLocationProvider(246): sv: 8 snr: 0.0 elev: 43.0 azimuth: 314.0 E A
07-31 11:54:59.883: V/GpsLocationProvider(246): sv: 9 snr: 0.0 elev: 36.0 azimuth: 312.0 E A
07-31 11:54:59.883: V/GpsLocationProvider(246): sv: 10 snr: 0.0 elev: 0.0 azimuth: 0.0 E A
07-31 11:54:59.883: V/GpsLocationProvider(246): sv: 13 snr: 0.0 elev: 39.0 azimuth: 188.0 E A
07-31 11:54:59.883: V/GpsLocationProvider(246): sv: 16 snr: 0.0 elev: 1.0 azimuth: 66.0 E A
So is this an Mono for android problem? The following code never triggers the ILocationListener:
[Register("requestLocationUpdates", "(Ljava/lang/String;JFLandroid/location/LocationListener;)V", "GetRequestLocationUpdates_Ljava_lang_String_JFLandroid_location_LocationListener_Handler")]
public virtual void RequestLocationUpdates(string provider, long minTime, float minDistance, ILocationListener listener);