简体   繁体   English

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

[英]Xamarin Forms How to get the name of the wi-fi network in which the device is connected

有谁知道如何获得设备当前连接的 wi-fi 网络的名称?

using Essentials使用Essentials

var orientation = DeviceDisplay.MainDisplayInfo.Orientation;

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

the solution to my problem, for now, I solved it this way:我的问题的解决方案,现在,我是这样解决的:

in the App.cs :在 App.cs 中:

public App () {公共应用(){

            MainPage =new NavigationPage( new HomePage());

    }

in the HomePage.xaml.cs :在 HomePage.xaml.cs 中:

protected override void OnSizeAllocated(double width, double height) {受保护的覆盖无效 OnSizeAllocated(双倍宽度,双倍高度){

        base.OnSizeAllocated(width, height);

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

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

in the TestPage.xaml.cs :在 TestPage.xaml.cs 中:

protected override void OnSizeAllocated(double width, double height) {受保护的覆盖无效 OnSizeAllocated(双倍宽度,双倍高度){

        base.OnSizeAllocated(width, height);

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

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

If anyone has any better ideas ...如果有人有更好的想法......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM