문제

While my app is working - I need to check, that GPS-location is on. I DO NOT need any complex things with statusChanged and other - just check a value of setting.

If that setting is off - I must stop execute current operation. I got one method, which called every time, when user execute operation. And I wanna place check rule there. So - it must be fast and cheap.

Is there any human way? Without keeping GPSWatcher ON all the time, and check his last status. I must care about battery.

Thanks.

도움이 되었습니까?

해결책

You can use this:

Geolocator geolocator = new Geolocator();

if (geolocator.LocationStatus == PositionStatus.Disabled)
{
    ...
}

다른 팁

According to the documentation

var accessStatus = await Geolocator.RequestAccessAsync();
switch (accessStatus)
{
case GeolocationAccessStatus.Allowed:

    break;

case GeolocationAccessStatus.Denied:
    _
    break;

case GeolocationAccessStatus.Unspecified:


    break;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top