Windows Phone 7 开发之检查手机网络
程序员文章站
2022-04-06 19:50:06
using system;
using system.collections.generic;
using system.linq;
using system.n...
using system;
using system.collections.generic;
using system.linq;
using system.net;
using system.windows;
using system.windows.controls;
using system.windows.documents;
using system.windows.input;
using system.windows.media;
using system.windows.media.animation;
using system.windows.shapes;
using microsoft.phone.controls;
using system.net.networkinformation;
using microsoft.phone.net.networkinformation;
namespace checknet
{
public partial class mainpage : phoneapplicationpage
{
private bool networkisavailable;
private networkinterfacetype _currentnetworktype; //网络连接的类型
public mainpage()
{
initializecomponent();
}
private void button1_click(object sender, routedeventargs e)
{
networkisavailable = microsoft.phone.net.networkinformation.networkinterface.getisnetworkavailable();//当前网络是否可用
_currentnetworktype = microsoft.phone.net.networkinformation.networkinterface.networkinterfacetype;//获取当前网络的类型
if (networkisavailable)
{
message.text = "联网状态"; www.2cto.com
message.background = new solidcolorbrush(colors.green);
}
else
{
message.text = "断网状态";
message.background = new solidcolorbrush(colors.red);
}
switch (_currentnetworktype)
{
case networkinterfacetype.mobilebroadbandcdma:
netname.text = "cdma网络";
break;
case networkinterfacetype.mobilebroadbandgsm:
netname.text = "csm网络";
break;
case networkinterfacetype.wireless80211:
netname.text = "wireless网络";
break;
case networkinterfacetype.ethernet:
netname.text = "ethernet网络";
break;
case networkinterfacetype.none:
netname.text = "网络不可用";
break;
default:
netname.text = "其他的网络";
break;
}
}
}
}
摘自 _亚
using system.collections.generic;
using system.linq;
using system.net;
using system.windows;
using system.windows.controls;
using system.windows.documents;
using system.windows.input;
using system.windows.media;
using system.windows.media.animation;
using system.windows.shapes;
using microsoft.phone.controls;
using system.net.networkinformation;
using microsoft.phone.net.networkinformation;
namespace checknet
{
public partial class mainpage : phoneapplicationpage
{
private bool networkisavailable;
private networkinterfacetype _currentnetworktype; //网络连接的类型
public mainpage()
{
initializecomponent();
}
private void button1_click(object sender, routedeventargs e)
{
networkisavailable = microsoft.phone.net.networkinformation.networkinterface.getisnetworkavailable();//当前网络是否可用
_currentnetworktype = microsoft.phone.net.networkinformation.networkinterface.networkinterfacetype;//获取当前网络的类型
if (networkisavailable)
{
message.text = "联网状态"; www.2cto.com
message.background = new solidcolorbrush(colors.green);
}
else
{
message.text = "断网状态";
message.background = new solidcolorbrush(colors.red);
}
switch (_currentnetworktype)
{
case networkinterfacetype.mobilebroadbandcdma:
netname.text = "cdma网络";
break;
case networkinterfacetype.mobilebroadbandgsm:
netname.text = "csm网络";
break;
case networkinterfacetype.wireless80211:
netname.text = "wireless网络";
break;
case networkinterfacetype.ethernet:
netname.text = "ethernet网络";
break;
case networkinterfacetype.none:
netname.text = "网络不可用";
break;
default:
netname.text = "其他的网络";
break;
}
}
}
}
摘自 _亚
上一篇: 男人嘴女人嘴经典超幽默
下一篇: 在非洲卖的很火的传音手机要上市了
推荐阅读
-
Windows Phone 7 开发 31 日谈——第12日:使手机震动
-
Windows Phone 7 开发之检查手机网络
-
Windows Phone 7 开发探索笔记3——触控操作之GestureListener
-
Windows Phone 7 开发探索笔记4——触控操作之XNA中的Gesture
-
Windows Phone 7 开发探索笔记2——触控操作之Manipulation
-
Windows Phone 7 开发探索笔记1——触控操作之Touch
-
Windows Phone 7 开发之Microsoft.Phone.Tasks中的各项Task
-
Windows Phone 7(WP7)开发 网络操作(1) HttpWebRequest基本的GET请求
-
Windows Phone 7(WP7)开发 网络操作(2) HttpWebRequest GET请求队列
-
Windows Phone 7 XNA开发之关于游戏组件