4

I'm a debutant in Android and I'm getting this error

E/libEGL: validate_display:99 error 3008 (EGL_BAD_DISPLAY)

while debugging my app. I'm trying to read an .epub3 file from assets with Webview, but I get a blank page.

Note: I'm using two libraries: slf4j and epublib-core.

This is the MainActivity class:

 webView = (WebView) findViewById(R.id.webview);
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webView.setWebViewClient(new WebViewClient());
    try {
        Book book = (new EpubReader( )).readEpub(new FileInputStream("adventures.epub"));
        String baseUrl = "file:///android_asset/";
        String data = new String(book.getContents( ).get(2).getData( ));
        webView.loadDataWithBaseURL(baseUrl, data, "text/html", "UTF-8", null);
    } catch (IOException e) {
        e.printStackTrace( );
    }

    AssetManager assetManager = getAssets( );
    try {
        // find InputStream for book
        InputStream epubInputStream = assetManager
                .open("adventures.epub");

        // Load Book from inputStream
        Book book = (new EpubReader( )).readEpub(epubInputStream);

        // Log the book's authors
        Log.i("epublib", "author(s): " + book.getMetadata( ).getAuthors( ));

        // Log the book's title
        Log.i("epublib", "title: " + book.getTitle( ));

        // Log the book's coverimage property
        Bitmap coverImage = BitmapFactory.decodeStream(book.getCoverImage( )
                .getInputStream( ));
        Log.i("epublib", "Coverimage is " + coverImage.getWidth( ) + " by "
                + coverImage.getHeight( ) + " pixels");

        // Log the tale of contents
        logTableOfContents(book.getTableOfContents( ).getTocReferences( ), 0);
    } catch (IOException e) {
        Log.e("epublib", e.getMessage( ));
    }
}

/**
 * Recursively Log the Table of Contents
 *
 * @param tocReferences
 * @param depth
 */
private void logTableOfContents(List<TOCReference> tocReferences, int depth) {
    if (tocReferences == null) {
        return;
    }
    for (TOCReference tocReference : tocReferences) {
        StringBuilder tocString = new StringBuilder( );
        for (int i = 0; i < depth; i++) {
            tocString.append("\t");
        }
        tocString.append(tocReference.getTitle( ));
        Log.i("epublib", tocString.toString( ));

        logTableOfContents(tocReference.getChildren( ), depth + 1);
    }
}}
zx485
  • 28,498
  • 28
  • 50
  • 59
Hà Nou
  • 41
  • 3

0 Answers0