Click here to Skip to main content
14,328,801 members
Rate this:
Please Sign up or sign in to vote.
See more:
If i put the link in chrome i view the page but if i put in code, i only have a blank page, this is the code:

public class WebActivity extends Activity {

    private WebView webView;

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.webcontent);

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

        webView.getSettings().setJavaScriptEnabled(true);

        webView.loadUrl("192.168.1.66/sir1415/teste/teste.html");


    }
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

I had the same issue and I fixed it setting the WebChromeClient for the WebView and load the URL using loadDataWithBaseURL

WebView wv = (WebView)findViewById(R.id.webview);
wv.setWebChromeClient(new WebChromClient());
WebViewClient wvclient = new WebViewClient() {
	@Override
	public boolean shouldOverrideUrlLoading(WebView view, String url) {
		Intent intent = new Intent(getApplicationContext(),
			YourActivity.class);
		String message = url;
		startActivity(intent);
		return true;
	        }
	};
	wv.setWebViewClient(wvclient);
	wv.getSettings().setJavaScriptEnabled(true);
	wv.getSettings().setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
	wv.loadDataWithBaseURL("http://www.yoursite.com", result,
					"text/html", "UTF-8", null);
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100