我需要始终启用wifi,因为我的应用程序处于活动状态。
我尝试过:
protected override void OnResume()
{
base.OnResume();
WifiManager wifiManager = (WifiManager)GetSystemService(Context.WifiService);
WifiManager.WifiLock wifiLock = wifiManager.CreateWifiLock(Android.Net.WifiMode.FullHighPerf, "SYNCVR");
wifiLock.Acquire();
PowerManager pm = (PowerManager)GetSystemService(Context.PowerService);
PowerManager.WakeLock wl = pm.NewWakeLock(WakeLockFlags.Full, "MyTag");
wl.Acquire();
}
//This timer is running every 10'' when i'm on Pause
private void Tmr_Elapsed(object sender, ElapsedEventArgs e)
{
ConnectivityManager connectivityManager = (ConnectivityManager)GetSystemService(Context.ConnectivityService);
NetworkInfo activeNetworkInfo = connectivityManager.ActiveNetworkInfo;
Write.LogFile(Convert.ToString(activeNetworkInfo));
}
但是当我处于暂停状态时,有时会收到消息
我还能尝试什么? 我不使用wifilock.release,因为我需要wifi始终在PauseMode上“打开”