我需要检查手机设置中的用户是否选择了4G或3G选项。
例如,如果用户系统设置为4G但
InternetConnectionProfile.WwanConnectionProfileDetails.GetCurrentDataClass();
将返回不同的值然后4G我可以将他重定向到手机设置(ms-settings-cellular://),以便他可以禁用4G。
但目前我无法检查当前用户系统设置。
答案 0 :(得分:0)
我在我的一个应用中使用了这个:
private const int IANA_INTERFACE_TYPE_WIFI = 71;
private static bool getCurrentConnection()
{
ConnectionProfile internetConnectionProfile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
// Check the connection details.
if (internetConnectionProfile.NetworkAdapter.IanaInterfaceType != IANA_INTERFACE_TYPE_WIFI)
{
// Connection is not a Wi-Fi connection.
return false;
//if (internetConnectionProfile.GetConnectionCost().Roaming)
//{
// // User is roaming. Don't send data out.
//}
//if (internetConnectionProfile.GetConnectionCost().ApproachingDataLimit)
//{
// // User is approaching data limit. Send low-resolution images.
//}
//if (internetConnectionProfile.GetConnectionCost().OverDataLimit)
//{
// // User is over data limit. Don't send data out.
//}
}
else
{
//Connection is a Wi-Fi connection. Data restrictions are not necessary.
return true;
}
}
您也可以尝试:How can I check for 3G, wifi, EDGE, Cellular Networks in Windows Phone 7?