Skip to main content

Read Epub File In WebView In Android

*****************************MainActivity.Java******************************************

public class MainActivity extends Activity {

    WebView v1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
       
        v1 = (WebView) findViewById(R.id.Wb1);
        v1.getSettings().setJavaScriptEnabled(true);
        v1.getSettings().setLoadWithOverviewMode(true);
        v1.getSettings().setUseWideViewPort(true);
        v1.loadUrl("file:///android_asset/ebook.epub");
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}

**************************activity_main.xml********************************************
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <WebView
            android:id="@+id/Wb1"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </LinearLayout>

Download Source Code :Click Here

Comments

Popular posts from this blog

Create Shared Prefrence Via XML In Android

Download Source Code : Click Here Output:

Sandeep Maheshwari on zee news

Network Security Exception in Android Retrofit Cleartext HTTP traffic not permitted

Create One directory in res/xml Create file in xml directory Past give below code : < network-security-config > < base-config cleartextTrafficPermitted= "true" /> < domain-config > < domain includeSubdomains= "true" >www.xyz.com</ domain >> < trust-anchors > < certificates src= "system" /> </ trust-anchors > </ domain-config > </ network-security-config > Add one Line into AndroidMenifest.xm File in application tag : android :networkSecurityConfig= "@xml/yourfilename" android :usesCleartextTraffic= "true"