mirror of
https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background
synced 2024-12-23 13:57:35 +00:00
Only activate the background mode if the location service is available
This commit is contained in:
parent
bc2b52e1b7
commit
a85644a75c
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user