In my application, I create a broadcast receiver that will listen for network changes. In OnReceive, it will check if the device is only connected to WiFi, and then start downloading in the background. No action will be shown, so what do I need to do to initialize the frame without a burst of activity? I don’t need any part of the navigation on the frame pages, so optimal initialization would be optimal.
private override void OnReceive(Context context, Intent intent)
{
bool isWifiConnected = false;
bool isMobileConnected = false;
if (intent.Action.Equals(ConnectivityManager.ConnectivityAction))
{
NetworkInfo networkInfo = (NetworkInfo)intent.GetParcelableExtra(ConnectivityManager.ExtraNetworkInfo);
if (networkInfo.IsConnected)
{
if (networkInfo.Type == (int)ConnectivityType.Wifi)
{
isWifiConnected = true;
}
if (networkInfo.Type == (int)ConnectivityType.Mobile)
{
isMobileConnected = true;
}
}
}
if (isWifiConnected)
{
StartUp();
}
source
share