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

问题描述 投票:0回答:2

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

c# xamarin.forms device-orientation
2个回答
0
投票

使用Essentials

var orientation = DeviceDisplay.MainDisplayInfo.Orientation;

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

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();
    }

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

© www.soinside.com 2019 - 2024. All rights reserved.