Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to load http url with instantApp webview?

I'm trying to make an instantApp and put a webView at the opening activity. When I add a url starts with https I can see the website on my webview. but when the url starts with http, I get an error:

net::ERR_CLEARTEXT_NOT_PERMITTED

Here is my code:

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


  }
}

Hope you can help me with that.

like image 809
zb22 Avatar asked Dec 28 '17 08:12

zb22


1 Answers

With reference to android Instant-App Document

All the network traffic from inside instant apps must use HTTPS. Instant apps does not support HTTP.

like image 168
Prags Avatar answered Sep 21 '22 05:09

Prags