webView does not work

1

I have a problem, my application does not load the URL link

The problem is that if I leave the application and load the same URL from the phone's browser, this url does work.

This is why I think it is not a network error, but some error within the application.

my cohoigo is this:

String urlMostrarGrafica = "http://www.fcv.org/SenInt/";
WebView wvPaginaPrincipal;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_visualizador);

    wvPaginaPrincipal = (WebView) findViewById(R.id.wvPaginaPrincipal);
    webView.setWebViewClient(new MyWebViewClient());
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    wvPaginaPrincipal.loadUrl(urlMostrarGrafica);   
}

public class MyWebViewClient extends WebViewClient
{
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }
}

in the manifiest I have:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

could help me solve the error porfa.

Thank you.

    
asked by william angel 07.05.2018 в 17:06
source

1 answer

-1

For the loading of the page that revises the code requires execution of JavaScript , you need to enable JavaScript but in the same instance of WebView ( wvPaginaPrincipal ), this would be the correct code:

   wvPaginaPrincipal = (WebView) findViewById(R.id.wvPaginaPrincipal);

   //webView.setWebViewClient(new MyWebViewClient());
   //WebSettings settings = webView.getSettings();
   //settings.setJavaScriptEnabled(true);

   wvPaginaPrincipal.setWebViewClient(new MyWebViewClient());
   WebSettings settings = wvPaginaPrincipal.getSettings();
   settings.setJavaScriptEnabled(true);

   wvPaginaPrincipal.loadUrl(urlMostrarGrafica);

    
answered by 07.05.2018 в 18:33