Skip to content

Commit

Permalink
Fixes #252 adds IsFromMockProvider on Android 18+
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed Jun 11, 2018
1 parent b30f37a commit 1988f06
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Geolocator.Plugin/Abstractions/Position.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public Position(Position position)
Accuracy = position.Accuracy;
Heading = position.Heading;
Speed = position.Speed;
IsFromMockProvider = position.IsFromMockProvider;
}

/// <summary>
Expand Down Expand Up @@ -109,6 +110,15 @@ public double Speed
get;
set;
}

/// <summary>
/// Gets or sets if from mock provider
/// </summary>
public bool IsFromMockProvider
{
get;
set;
}
}

/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions src/Geolocator.Plugin/Android/GeolocationUtils.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ internal static Position ToPosition(this Location location)
p.Longitude = location.Longitude;
p.Latitude = location.Latitude;
p.Timestamp = location.GetTimestamp();

if ((int)Android.OS.Build.VERSION.SdkInt >= 18)
p.IsFromMockProvider = location.IsFromMockProvider;
else
p.IsFromMockProvider = false;

return p;
}

Expand Down

8 comments on commit 1988f06

@mina5500
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how to use IsFromMockProvider?
i am using Xamarin forms portable project
i use this line to get geo location
var position = await CrossGeolocator.Current.GetPositionAsync(new TimeSpan(0, 0, 0, 0, 500));

i need to know if the returened location is fake or not .... can you please help @jamesmontemagno ?

@jamesmontemagno
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is a property on the location that is returned.

@mina5500
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not available in returned position properties @jamesmontemagno
image

@mina5500
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any updates ? @jamesmontemagno

@chrisfoulds
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is there an it works as when I use Lockito to test that flag is set.

https://github.com/jamesmontemagno/GeolocatorPlugin/blob/master/src/Geolocator.Plugin/Abstractions/Position.shared.cs

You can clearly see it is a part of code, if you are not seeing it you must be having issues outside the plugin.
BTW : As this nuget is not overly maintained anymore in favour of the yet not on feature parity xamarin essentials I simply forked the code into a private repo and update it myself now. Might be worth doing the same yourself if you are building a serious application.

@jamesmontemagno
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, maybe uninstall and re-install... it is there for me....

@jamesmontemagno
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh it is in the pre-release nuget, that is why you don't see it :)

@mina5500
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes i found it :-) when i upgraded to latest pre-release.... but is it safe to put a beta nuget into a fully working application that will be published on PlayStore and AppStore ? @jamesmontemagno
my application uses geo for employees attendance (IN/OUT) ...

Please sign in to comment.