Click here to Skip to main content
15,886,780 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:

JavaScript
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

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);
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900