Xamarin Forms如何获取连接设备的Wi-Fi网络的名称

时间:2019-08-13 14:37:10

标签: c# xamarin.forms device-orientation

有人知道如何使用设备当前连接的Wi-Fi网络的名称吗?

2 个答案:

答案 0 :(得分:0)

使用Essentials

var orientation = DeviceDisplay.MainDisplayInfo.Orientation;

if (orientation == Orientation.Landscape) 
{
  MainPage = new Page1();
} else {
  MainPage = new Page2();
}

答案 1 :(得分:0)

解决我的问题的方法,目前,我是这样解决的:

在App.cs中:

公共应用()         {

            MainPage =new NavigationPage( new HomePage());

    }

在HomePage.xaml.cs中:

受保护的覆盖无效OnSizeAllocated(双倍宽度,双倍高度)         {

        base.OnSizeAllocated(width, height);

        if(width > height)
        {
            _ = GoToPageAsync();
        }
    }

    private  async Task GoToPageAsync()
    {
        await Navigation.PushAsync(new TestPage());
    }

在TestPage.xaml.cs中:

受保护的覆盖无效OnSizeAllocated(双倍宽度,双倍高度)         {

        base.OnSizeAllocated(width, height);

        if (width < height)
        {
            _ = GoToPageAsync();
        }
    }

    private async Task GoToPageAsync()
    {
        await Navigation.PopAsync();
    }

如果有人有更好的主意...

相关问题