문제

I recently installed the Windows Phone 8.1 emulators to try some existing apps out on them and ran into this problem: DeviceNetworkInformation.IsCellularDataEnabled (in the Microsoft.Phone.Net.NetworkInformation namespace) is always returning false.

public void UpdateDataEnabled()
{
    _dataEnabled = DeviceNetworkInformation.IsCellularDataEnabled 
        || DeviceNetworkInformation.IsWiFiEnabled;
}

DeviceNetworkInformation.IsCellularDataEnabled = false

I know the connection is actually working because I'm still able to perform HTTP requests. If I run this same exact code in the 8.0.x emulators I don't have any problems.

I also tried updating the project and all libraries to Windows Phone Silverlight 8.1 apps to see if that would resolve the issue and no luck. I checked all the capabilities and ID_CAP_NETWORKING was still checked as well.

The emulator is tested and working if I write a pure Windows Phone 8.1 XAML app using Windows 8 method of obtaining network status. It's just not working for my Silverlight apps.

I was under the impression that Windows Phone Silverlight apps should continue to function on Windows Phone 8.1 devices. Am I overlooking something?

도움이 되었습니까?

해결책

I have the same problem and i did what verdesrobert and Rishabh876 suggested. Its only emulator problem so i add condition to check out if app is running on emulator

    public bool IsNetworkAvailable()
    {
        if (DeviceNetworkInformation.IsNetworkAvailable)
        {
            if (Microsoft.Devices.Environment.DeviceType == DeviceType.Emulator)
            {
                return true;
            }
            else if ((DeviceNetworkInformation.IsWiFiEnabled || DeviceNetworkInformation.IsCellularDataEnabled) && NetworkInterface.NetworkInterfaceType != NetworkInterfaceType.None)
            {
                return true;
            }
        }
        return false;
    }

I dont like that workaround much so if anyone has better solution let me know.

다른 팁

It seems that the WP8.1 emulator is giving that information only to WP8.1 apps.
I'm pretty sure that the 7.1 apps will work properly on WP8.1 Devices.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top