To show a static html page in android

I am trying to show an html file in my assets folder but in web view i am seeing white blank page. I got similar example from stackflow only.

 public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    final String mimeType="text/html";
    final String encoding="UTF-8";
    String htmlString="<html><body>";
    Document doc;
    WebView wv= new WebView(this);
    Elements link = null;


    setContentView(wv);
    try{
        InputStream in=getAssets().open("myweb.html");
        byte[] buffer= new byte[in.available()];
        in.read(buffer);
        in.close();
        wv.loadData(new String(buffer), mimeType, encoding);
    }
    catch(IOException e)
    {
        Log.d("MyWebView", e.toString());
    }
}

  • ProGuard: Warning: butterknife.internal.InjectViewProcessor:
  • What the equivalent of activity life cycle in iOS?
  • How to solve the issue with Dalvik compiler limitation on 64K methods?
  • Set up Slidemenu - example not working
  • Intent from notification does not have extras
  • Any photo gallery library for Android?
  • Access the SIM Card with an Android Application?
  • Render epub files in android
  • Android DataBinding where to get context?
  • Android : 4.0.3 emulator closed automatically after some time
  • Screen record Android Wear
  • How do I import a CA certificate into Android 4.4.2 in the emulator?
  • 4 Solutions collect form web for “To show a static html page in android”

    you can load the content of the web view using

    // add a webview with id @+id/the_webwiev to your main.xml layout file
    WebView wv = (WebView)findViewById(R.id.the_webview);
    wv.loadUrl("file:///android_asset/myweb.html");
    

    Uhm, did you try following the WebView example from the official webpage? It’s really simple.

    http://developer.android.com/resources/tutorials/views/hello-webview.html

    I followed that and had no trouble implementing a WebView. Your code looks overly complicated for something that is quite simple.

    If your file is called pmi_help.html (and located in the /assets/ folder), you load it using:

        mWebView.loadUrl("file:///android_asset/pmi_help.html");
    

    Put your html page in asset > www, then load:

    mWebView.loadUrl("file:///android_asset/index1.html");
    

    Anyway, don’t forget this:
    Before this will work, however, your application must have access to the Internet. To get Internet access, request the INTERNET permission in your manifest file. For example:

    <manifest ... >
        <uses-permission android:name="android.permission.INTERNET" />
        ...
    </manifest>
    
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.