【发布时间】:2020-01-12 15:46:36
【问题描述】:
有没有办法可以使用插件来做到这一点,或者我是否需要编写某种自定义渲染器?
【问题讨论】:
标签: xamarin xamarin.forms
有没有办法可以使用插件来做到这一点,或者我是否需要编写某种自定义渲染器?
【问题讨论】:
标签: xamarin xamarin.forms
// Operating System Version Number (7.0)
var version = DeviceInfo.VersionString;
// Platform (Android)
var platform = DeviceInfo.Platform;
【讨论】:
if (DeviceInfo.Version.Major >= 11) { // .... }
你也可以使用Xam.Plugin.DeviceInfo。
Xam.Plugin.DeviceInfo:https://www.nuget.org/packages/Xam.Plugin.DeviceInfo
代码:在 App.cs 中
// The root page of your application
MainPage = new ContentPage
{
Content = new StackLayout
{
Padding = 50,
VerticalOptions = LayoutOptions.Center,
Children = {
new Label{ Text = "Id: " + CrossDeviceInfo.Current.Id},
new Label{ Text = "Model: " + CrossDeviceInfo.Current.Model},
new Label{ Text = "Platform: " + CrossDeviceInfo.Current.Platform},
new Label{ Text = "Version: " + CrossDeviceInfo.Current.Version},
}
}
};
您可以从链接下载源代码以供参考。 https://github.com/jamesmontemagno/DeviceInfoPlugin
【讨论】: