【问题标题】:how to load http url with instantApp webview?如何使用 InstantApp webview 加载 http url?
【发布时间】:2017-12-28 08:12:14
【问题描述】:

我正在尝试制作一个 instantApp 并将 webView 放在开幕活动中。 当我添加一个以 https 开头的 url 时,我可以在我的 webview 上看到该网站。 但是当 url 以 http 开头时,我得到一个错误:

net::ERR_CLEARTEXT_NOT_PERMITTED

这是我的代码:

public class HelloActivity extends AppCompatActivity {

WebView webView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_hello);

    webView = (WebView)findViewById(R.id.webView1);
    webView.setWebViewClient(new WebViewClient());


    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setUseWideViewPort(true);
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setPluginState(WebSettings.PluginState.ON);

    webView.loadUrl("http://www.foxnews.com/");

    // webView.loadUrl("https://www.google.com"); this url is working


  }
}

希望你能帮助我。

【问题讨论】:

  • 为什么你不想用https的那个?
  • 因为 Android Instant Apps 不支持 http 网站。

标签: android http android-instant-apps


【解决方案1】:

参考androidInstant-App Document

免安装应用内部的所有网络流量都必须使用HTTPS。免安装应用not support HTTP。

【讨论】:

    猜你喜欢
    • 2018-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-13
    • 2011-03-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多