是否可以通过编程方式选择数据连接类型(WiFi / GSM),并且可能同时进行数据传输? [英] Is it possible to choose the data connection type (WiFi / GSM) programmatically and possibly have a simultaneous data transfer on both?

查看:45
本文介绍了是否可以通过编程方式选择数据连接类型(WiFi / GSM),并且可能同时进行数据传输?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过编程方式选择数据连接类型(WiFi / GSM),并且可能同时进行数据传输?



Enzo CONTINI

Is it possible to choose the data connection type (WiFi / GSM) programmatically and possibly have a simultaneous data transfer on both?


Enzo CONTINI

推荐答案

 

您无法以编程方式选择数据连接类型,也无法在GSM和WiFi之间设置优先级。但您可以以编程方式打开设置屏幕,用户可以在它们之间进行选择。

 Hi,

You cannot chose data connection type programmatically and cannot set priority Between GSM and WiFi. But You Can Open Settings Screen Programmatically and user can choose between them.

您还可以通过以下方式查看此用户使用的是移动电话数据或WiFi。

And you can also see at this user is on Cellular data or on WiFi with below method.

//打开Wifi设置屏幕//

// Open Wifi Setting Screen//

Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-wifi:"));

// Open Cellular Settings Screen //


Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-cellular:"));


If You Want To Check That Currently User On Wifi Or Cellular Data Then Below Code Will Tell You That.

使用Microsoft.Phone.Net.NetworkInformation;

using Microsoft.Phone.Net.NetworkInformation;

DeviceNetworkInformation.NetworkAvailabilityChanged + =新的EventHandler< NetworkNotificationEventArgs>(NetworkChangeDetected);



  void NetworkChangeDetected(object sender,NetworkNotificationEventArgs e)

        {

            //我们正在进行UI更新,因此请确保在UI线程上发生这些更新。

            Dispatcher.BeginInvoke(()=>

            {

  &NBSP;&NBSP;&NBSP;&NBSP;布尔IsCellularData =((DeviceNetworkInformation.IsNetworkAvailable)及;及(DeviceNetworkInformation.IsCellularDataEnabled))真:假;

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;布尔IsWifiData =(DeviceNetworkInformation.IsWiFiEnabled)真:假;

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;  });
$


        }

DeviceNetworkInformation.NetworkAvailabilityChanged += new EventHandler<NetworkNotificationEventArgs>(NetworkChangeDetected);

 void NetworkChangeDetected(object sender, NetworkNotificationEventArgs e)
        {
            // We are making UI updates, so make sure these happen on the UI thread.
            Dispatcher.BeginInvoke(() =>
            {
      bool IsCellularData = ((DeviceNetworkInformation.IsNetworkAvailable) && (DeviceNetworkInformation.IsCellularDataEnabled)) ? true : false;
            bool IsWifiData= (DeviceNetworkInformation.IsWiFiEnabled) ? true : false;
            });

        }


这篇关于是否可以通过编程方式选择数据连接类型(WiFi / GSM),并且可能同时进行数据传输?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆