Android WebView document.location not working

Viewed 136

I am developing an application in html5 in android. I am learning to develop apps on the android studio, but I have a problem. "I have an index.html" which I display perfectly, where there are 3 buttons to link to 3 other Html pages. When I click on the button the app gives me an error. My activity class is as follows:

public class MainActivity extends AppCompatActivity {

    private WebView wv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        wv=(WebView)findViewById(R.id.web);
        WebSettings webSettings = wv.getSettings();

        webSettings.setJavaScriptEnabled(true);
        wv.loadUrl("file:///android_asset/index.html");
    }
}

The html code of the 3 buttons in the index.html is as following:

<div class="conBtnIntro"><input type="button" value="Addizione" onclick="document.location='summ.html';" id="btn1"class="btnIntro"/></div>
<div class="conBtnIntro"><input type="button" value="Sottrazione" onclick="document.location='diff.html';" id="btn2"class="btnIntro"/></div>
<div class="conBtnIntro"><input type="button" value="Moltiplicazione" onclick="document.location='product.html';" id="btn3"class="btnIntro"/></div>

Where am I wrong?

1 Answers

Have you added it to the manifest? There is a file called manifest.java in android studio project you need to extend the properties of Mainactivity!

Related