Which is the difference between Geolocation.Default.GetLocationAsync() and Geolocation.GetLocationAsync() (MAUI Android)

huangapple go评论69阅读模式
英文:

Which is the difference between Geolocation.Default.GetLocationAsync() and Geolocation.GetLocationAsync() (MAUI Android)

问题

Geolocation.Default.GetLocationAsync()和Geolocation.GetLocationAsync()之间有什么区别?

我已经尝试过两者,但我看不出区别。

谢谢。

英文:

Which is the difference between Geolocation.Default.GetLocationAsync() and Geolocation.GetLocationAsync()?

I have tried both and I don't see the difference.

Thanks.

答案1

得分: 0

它们都可以返回设备的当前位置。然而,Geolocation.Default 提供了这个 API 的静态用法的默认实现:

public static Microsoft.Maui.Devices.Sensors.IGeolocation Default { get; }

也就是说,如果你在 MAUI 中使用 GetLocationAsync(),建议使用 Geolocation.Default.GetLocationAsync()

要了解更多信息,你可以参考下面的链接:

https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/device/geolocation?tabs=android

https://learn.microsoft.com/en-us/dotnet/api/microsoft.maui.devices.sensors.geocoding.default?view=net-maui-7.0

英文:

They all can return the current location of the device. However, the Geolocation.Default provides the default implementation for static usage of this API:

public static Microsoft.Maui.Devices.Sensors.IGeolocation Default { get; }

That said, if you are using the GetLocationAsync() in MAUI, it's recommended to use Geolocation.Default.GetLocationAsync().

For more information, you can refer to the links below:

https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/device/geolocation?tabs=android

https://learn.microsoft.com/en-us/dotnet/api/microsoft.maui.devices.sensors.geocoding.default?view=net-maui-7.0

huangapple
  • 本文由 发表于 2023年5月17日 23:20:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76273698.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定