英文:
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
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论