【问题标题】:Webview and metered connectionWebview 和计量连接
【发布时间】:2016-02-02 10:10:23
【问题描述】:

美好的时光!

我在 Windows 10 UWP 项目中有一个 webview 控件。当用户打开一些详细信息页面时,他看到了导航到本地 html 字符串的 web 视图。

我需要说 webview 不会从互联网加载任何数据(例如图像、视频、flash 和其他内容)。我只想显示 HTML 字符串。

Webview 总是加载所有内容,我该如何覆盖这个逻辑?

【问题讨论】:

  • SYL,您需要添加代码,以便我们知道哪里出了问题。但我有一个很大的预感,在您的详细信息页面 Webview 中,您没有任何 HTML 标记,甚至没有 XML 标记。只是普通的图像源或嵌入的 Vidplayer 位置。但我们还不能确定,您必须向我们提供代码。
  • @Aizen,就我而言,我有一个从网络加载的 HTML 文档。该文档可以包含任何 nedia 数据,如视频、flash、图像等。我需要通过 webview 控件向用户显示此文档,但如果用户使用计量连接,我需要说 webview 不要从互联网加载任何数据,只需显示字符串内容。我该怎么做?

标签: c# xaml win-universal-app windows-10-universal windows-10-mobile


【解决方案1】:

您可以区分您的互联网是蜂窝数据还是 Wifi,如下所示:

var connectionProfile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();

if (connectionProfile.IsWlanConnectionProfile)
{
     // It's wireless
     // You can load images, videos, etc. (your business here).
}
else if (connectionProfile.IsWwanConnectionProfile)
{  
     // It's mobile.
     // You'll probably want to perform some handling 
     // to inform the user that your items are not loaded 
     // because they're using a metered connection.
}

答案来自 here,最初回答了这个问题。

【讨论】:

  • 好的,但是webview总是加载图片,我不知道怎么覆盖这个逻辑))
猜你喜欢
  • 2016-03-14
  • 1970-01-01
  • 2021-10-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多