1

I am trying to load an html file into a webview but the webview remains blank. Can someone please help me to achieve this ?

here is my html

<script src="http://france.meteofrance.com/portlet/plugins/meteo/VignetteMeteoVille3.javascript?idLieu=431200" charset="UTF-8"></script> 

this is on create method

//oncreate method

protected void onCreate(Bundle savedInstanceState) {

    // TODO Auto-generated method stub

    super.onCreate(savedInstanceState);

    setContentView(R.layout.rss_feed);

     webcontent = (WebView)findViewById(R.id.webViewHistoire);

     webcontent.setWebViewClient(new NewsClient());

     webcontent.getSettings().setJavaScriptEnabled(true);

     webcontent.getSettings().setPluginsEnabled (true);

     webcontent.getSettings().setDomStorageEnabled(true);

     webcontent.loadUrl("file:///android_asset/home.html");


}

//back key

public boolean onKeyDown(int keyCode, KeyEvent event) {

    if ((keyCode == KeyEvent.KEYCODE_BACK) && webcontent.canGoBack()) {

        webcontent.goBack();    

        return true;

    }

    return super.onKeyDown(keyCode, event);

}

private class NewsClient extends WebViewClient {

    public boolean shouldOverrideUrlLoading(WebView view, String url) {

        return true;
    }
}
5
  • please refer developer.android.com/guide/webapps/webview.html Commented Jan 4, 2013 at 4:51
  • Grishu i have updated the post Commented Jan 4, 2013 at 5:06
  • the html file is in assets folder Commented Jan 4, 2013 at 5:06
  • did you tried with any phonegap android samples.. in that you will have the idea to call javascript file using html.. from android webview. Commented Jan 4, 2013 at 5:13
  • Did you add <uses-permission android:name="android.permission.INTERNET"/> to your manifest.xml file?? Commented Jan 4, 2013 at 5:24

1 Answer 1

1

Is your html file code written in <html> tag ? if not then please write it as below:

<html> 
  <head>
 <script language="JavaScript"  src="http://france.meteofrance.com/portlet/plugins/meteo/VignetteMeteoVille3.javascript?idLieu=431200" charset="UTF-8">
 </script>
 </head>
  </html> 

And try to load it in webview.

Sign up to request clarification or add additional context in comments.

1 Comment

yes it is in the body tag it is working fine when loaded in pc browser

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.