Only activate the background mode if the location service is available

This commit is contained in:
Sebastián Katzer 2013-12-09 11:39:21 +01:00
parent bc2b52e1b7
commit a85644a75c

View File

@ -86,7 +86,7 @@ namespace Cordova.Extension.Commands
/// </summary>
public static void Activate ()
{
if (Geolocator == null && isEnabled)
if (Geolocator == null && isEnabled && IsServiceAvailable())
{
Geolocator = new Geolocator();
@ -109,5 +109,13 @@ namespace Cordova.Extension.Commands
}
private static void geolocator_PositionChanged (Geolocator sender, PositionChangedEventArgs args) {}
/// </summary>
/// Gibt an, ob der Lokalisierungsdienst verfügbar ist
/// </summary>
private static bool IsServiceAvailable()
{
return !(Geolocator.LocationStatus == PositionStatus.Disabled || Geolocator.LocationStatus == PositionStatus.NotAvailable);
}
}
}