Android: InputStream

1

Is there a way I can change:

InputStream is = getAssets().open("xxx.html");

To:

InputStream is = ("http://www.xxx.com.br/xxx.html");

Maybe using HttpURLConnection but I do not know how to implement it.

Here's a piece of my code where I'm trying to implement this:

try {
     InputStream is = getAssets().open("xxx.html");
     String data = getResultFromStream(is);

     WebSettings ws = webView.getSettings();
     ws.setJavaScriptEnabled(true);
     ws.setJavaScriptCanOpenWindowsAutomatically(true);
     ws.setDomStorageEnabled(true);

     MyWebChromeClient chromeClient = new MyWebChromeClient();
     MyWebViewClient webViewClient = new MyWebViewClient();

     webView.setWebChromeClient(chromeClient);
     webView.setWebViewClient(webViewClient);
     webView.setBackgroundColor(0);
     webView.loadData(data, "text/html", "UTF-8");

     } catch (IOException e) {
        e.printStackTrace();
     } catch (Exception e) {
        e.printStackTrace();
     }
    
asked by anonymous 31.07.2014 / 17:10

1 answer

1

Try using

try {


 WebSettings ws = webView.getSettings();
 ws.setJavaScriptEnabled(true);
 ws.setJavaScriptCanOpenWindowsAutomatically(true);
 ws.setDomStorageEnabled(true);

 MyWebChromeClient chromeClient = new MyWebChromeClient();
 MyWebViewClient webViewClient = new MyWebViewClient();

 webView.setWebChromeClient(chromeClient);
 webView.setWebViewClient(webViewClient);
 webView.setBackgroundColor(0);
 webView.loadUrl("http://www.xxx.com.br/xxx.html");

 } catch (IOException e) {
    e.printStackTrace();
 } catch (Exception e) {
    e.printStackTrace();
 }
    
31.07.2014 / 19:46