webView.loadUrl is not working
android, html, java, webview
Solution
// Find view in layout
WebView wv = (WebView) findViewById(R.id.webView_tobe_loaded);
// Get settings
WebSettings wbset = wv.getSettings();
// Enable JavaScript
wbset.setJavaScriptEnabled(true);
// Set new client (to handle website in your app)
wv.setWebViewClient(new MyWebViewClient());
// Example of the URL
String url = "http://www.google.com";
// Load website
wv.loadUrl(url);
This code will help you to solve the problem. It worked for me.
Problem
This is my code: ``` package sai.datla.game; import android.app.Activity; import android.os.Bundle; import android.webkit.WebChromeClient; import android.webkit.WebView; public class GametestActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); WebView webView = (WebView)findViewById(R.id.webView); webView.getSettings().setJavaScriptEnabled(true); webView.setWebChromeClient(new WebChromeClient()); webView.clearSslPreferences(); webView.loadUrl("file:///android_asset/www/index.html"); } } ``` but it is saying that it cannot find the link in the emulator. I have checked many times if my index.html file is in the www folder, which is in my assets, but it won't work. Please help. By the way I am only twelve years old so please make the answers easy to understand for a child.