Working with ePub files in android

I called it the siegmann android tutorial and successfully completed the registration Title, Author nameand Table of contents.

Now I read that the whole book can be viewed at WebView.

But I do not find a tutorial for Dispalying an ePub file.

When it comes to creating an ePub file, I found it from SO But I can not implement it since I have no idea about main.xml.

Please offer any tutorial for creating and displaying an ePub file.

To create an ePub, I tried to reference this siegmann, for example, but I can’t get it right.

Do I need to provide an ePub file .htmlfor each chapter .css?

I know that I am a little unclear on this issue, as I am absolutely new when it comes to working with ePub, so any suggestions / help are appreciated.

+5
source share
2 answers

Try it in logTableOfContents()

while ((line = r.readLine()) != null) {

line1 = line1.concat(Html.fromHtml(line).toString());

}

finalstr = finalstr.concat("\n").concat(line1);
+2
source

You can also cut the contents of epub with

        Spine spine = book.getSpine(); 
        List<SpineReference> spineList = spine.getSpineReferences() ;
        int count = spineList.size();
        StringBuilder string = new StringBuilder();
        for (int i = 0; count > i; i++) {
            Resource res = spine.getResource(i);
            try {
                InputStream is = res.getInputStream();
                BufferedReader reader = new BufferedReader(new InputStreamReader(is));
                try {
                    while ((line = reader.readLine()) != null) {
                        linez =   string.append(line + "\n").toString();
                        System.err.println("res media"+res.getMediaType());
                        htmlTextStr = Html.fromHtml(linez).toString();
                        Log.e("Html content.",htmlTextStr);
                        speak(htmlTextStr);
                    }
                } catch (IOException e) {e.printStackTrace();}

                //do something with stream
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        webview.getSettings().setAllowFileAccess(true);
        webview.getSettings().setBuiltInZoomControls(true);
        webview.getSettings().setJavaScriptEnabled(true);

        webview.loadDataWithBaseURL("file:///android_asset/", linez, "application/xhtml+xml", "UTF-8", null);
+1
source

All Articles