没有Internet连接时检测网络漫游 [英] Detect network roaming when there is no Internet connection

查看:126
本文介绍了没有Internet连接时检测网络漫游的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下午好 


我想检测网络漫游,而Windows Phone 8和8.1上没有互联网连接。我使用此代码来确定它是否正在漫游:

 ConnectionProfile profile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile(); 
if(profile == null)
返回false;
else
返回profile.GetConnectionCost()。漫游;

当有Internet访问时,它可以很容易地发现用户正在漫游。但是,如果没有连接且ConnectionProfile返回null,则会出现此问题。我搜索网络检测网络漫游,但没有成功。建议使用
来使用MNC和MCC,但Windows Phone不提供此类信息或任何详细的网络信息。我试图在Android telephonyManager.isNetworkRoaming()中找到一个函数,但是使用了之前的结果。我的问题:是否有一个函数,
API或方法来检测用户是否正在漫游,但是当互联网连接断开时?


最好的问候


David

解决方案

试试..


Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation.IsCellularDataRoamingEnabled


Good afternoon 

I would like to detect network roaming, while there is not Internet connection on Windows Phone 8 and 8.1. I used this code to determine if it is roaming:

ConnectionProfile profile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
			if (profile == null)
				return false;
			else
				return profile.GetConnectionCost().Roaming;

It can easily find that user is in roaming when there is an Internet access. However the problem occurs when there is not the connection and the ConnectionProfile returns null. I searched the internet for detecting network roaming, but with no success. It was suggested to use MNC and MCC, but the Windows Phone doesn't provide such information or any detailed network info. I tried to find a function like in Android telephonyManager.isNetworkRoaming(), but with the previous result. My question: is there a function, API or method to detect that user is in roaming, but when the Internet connection is down?

Best Regards

David

解决方案

Try..

Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation.IsCellularDataRoamingEnabled


这篇关于没有Internet连接时检测网络漫游的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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