【发布时间】:2018-05-16 07:22:48
【问题描述】:
我尝试在我的 Xamarin Ui 测试中以编程方式启用/禁用 wifi。
我已经找到了这个:Android: How to Enable/Disable Wifi or Internet Connection Programmatically。但它似乎不适用于 UiTest。
我也尝试过这样的事情:
Context appContext = Android.App.Application.Context;
var wifiManager = (WifiManager)appContext.GetSystemService(Context.WifiService);
bool status = false;
wifiManager.SetWifiEnabled(status);
第一行(Android.App.Application.Context)抛出异常:
Message: System.IO.FileNotFoundException : Could not load file or assembly 'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' or one of its dependencies. The system cannot find the file specified.
我正在使用以下命名空间:
using Android.Net.Wifi;
using Android.Content;
我的项目引用了Mono.Android。
【问题讨论】:
-
将其作为方法添加到您的
Xamarin.Android项目中,并将其公开为可以通过 UITest 代码调用的后门。
标签: android xamarin xamarin.uitest