Android的EPUB库,skyepub [英] android epub library, skyepub

查看:1624
本文介绍了Android的EPUB库,skyepub的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我triyng创建一个EPUB阅读器为Android,所以在很多搜索我发现skyepub库(SDK)。看来,这是我所想要的所有功能。

我跟着网站的啧啧,但在运行codeI后,得到了一个黑屏和不同的logcat针对不同的API,我检查了code一次agian但我可以找不到什么是错的。

这是我的code和的logcat,任何帮助,将AP preciated。

 公共无效makeLayout()
{
    字符串文件名=新的String();
    文件名=AliceinWonderland.epub;
    makeSetup(); //使得在设备目录和每一个东西复制到
    RV =新ReflowableControl(本); // RV是ReflowableControl。一个EPUB类(视图)展示内容
    位图pageCenter = BitmapFactory.de codeFILE(getFilesDir()getAbsolutePath()+/images/PagesCenter.png);
    位图pageStack = BitmapFactory.de codeFILE(getFilesDir()getAbsolutePath()+/images/PagesStack.png);

    rv.setPagesStackImage(pageStack);
    rv.setPagesCenterImage(pageCenter);
    rv.setBaseDirectory(getFilesDir()+/书);
    rv.setBookName(文件名);

    rv.setDoublePagedForLandscape(真正的);
    rv.setFont(TimesRoman,26);
    rv.setLineSpacing(135);
    rv.setHorizo​​ntalGapRatio(0.15);
    rv.setVerticalGapRatio(0.1);

    / *
     *所有监听器类是实现缺省类的库一样简单的覆盖方法
     *公共无效的onClick(INT X,int y)对
     * {
     * Log.w(:EPUB,+ X +点击在检测到+ Y);
     *}
     * /

    rv.setHighlightListener(新HighlightDelegate());
    rv.setPageMovedListener(新PageMovedDelegate());
    rv.setSelectionListener(新SelectionDelegate());
    rv.setPagingListener(新PagingDelegate());
    rv.setSearchListener(新SearchDelegate());
    rv.setStateListener(新StateDelegate());
    rv.setClickListener(新ClickDelegate());
    rv.setBookmarkListener(新BookmarkDelegate());
    ContentHandler的CL =新的ContentHandler();
    rv.setContentListener(CL);

    rv.setStartPositionInBook(0.285714f);
    rv.setNavigationAreaWidthRatio(0.4f);

    RelativeLayout.LayoutParams PARAMS =新RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT,RelativeLayout.TRUE);
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP,RelativeLayout.TRUE);
    params.width = LayoutParams.MATCH_PARENT;
    params.height = LayoutParams.MATCH_PARENT;
    rv.setLayoutParams(PARAMS);

    ePubView =新RelativeLayout的(这一点);
    RelativeLayout.LayoutParams RLP =新RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT);
    ePubView.setLayoutParams(RLP);
    ePubView.addView(RV);

    的setContentView(ePubView);
}

公共无效makeSetup()
{
    如果(this.isSetup())回报;
    如果(!this.makeDirectory(脚本))
    {
        调试(faild使scripts目录);
    }

    如果(!this.makeDirectory(图像))
    {
        调试(faild,使图像目录);
    }

    如果(!this.makeDirectory(盖))
    {
        调试(faild,使图像目录);
    }

    copyImageToDevice(PagesCenter.png);
    copyImageToDevice(PagesStack.png);
    如果(!this.makeDirectory(下载))
    {
        调试(faild,使下载目录);
    }

    如果(!this.makeDirectory(书))
    {
        调试(faild,使书目录);
    }

    如果(!this.makeDirectory(书籍/字体))
    {
        调试(faild,使字体目录);
    }

    copyBookToDevice(AliceinWonderland.epub);

    copyFontToDevice(arial.ttf);
    copyFontToDevice(simpo.ttf);
    copyFontToDevice(tahoma.ttf);
    copyFontToDevice(TIMES.TTF);

    共享preferences preF = this.getShared preferences(EPubTest,0);
    共享preferences.Editor编辑= pref.edit();

    edit.putBoolean(isSetup,真正的);
    edit.commit();
}

私人布尔isSetup()
{
    共享preferences preF = this.getShared preferences(EPubTest,0);
    返回pref.getBoolean(isSetup,假);
}

公共布尔makeDirectory(字符串目录名)
{
    布尔水库;
    字符串文件路径=新的String(this.getFilesDir()getAbsolutePath()+/+目录名称。);
    调试(文件路径);
    档案文件=新的文件(文件路径);
    如果(!file.exists()){
        RES = file.mkdirs();
    }其他 {
        RES = FALSE;
    }
    返回水库;
}

公共无效copyImageToDevice(字符串文件名)
{
    尝试
    {
        字符串路径= this.getFilesDir()getAbsolutePath()+/图片/+文件名。
        档案文件=新的文件(路径);
        如果(file.exists())回报;
        InputStream的localInputStream = this.getAssets()打开(图像/+文件名)。
        FileOutputStream中localFileOutputStream =新的FileOutputStream(this.getFilesDir()getAbsolutePath()+/图片/+文件名);

        byte []的arrayOfByte =新的字节[1024];
        INT抵消;
        而((偏移= localInputStream.read(arrayOfByte))大于0)
        {
            localFileOutputStream.write(arrayOfByte,0,偏移量);
        }
        localFileOutputStream.close();
        localInputStream.close();
        Log.d(EPUB,文件名+复制到手机);
    }
    赶上(IOException异常localIOException)
    {
        localIOException.printStackTrace();
        Log.d(EPUB,无法复制);
        返回;
    }
}

公共无效copyBookToDevice(字符串文件名)
{
    尝试
    {
        字符串路径= this.getFilesDir()getAbsolutePath()+/书籍/+文件名。
        档案文件=新的文件(路径);
        如果(file.exists())回报;
        InputStream的localInputStream = this.getAssets()开(书籍/+文件名)。
        FileOutputStream中localFileOutputStream =新的FileOutputStream(this.getFilesDir()getAbsolutePath()+/书籍/+文件名);

        byte []的arrayOfByte =新的字节[1024];
        INT抵消;
        而((偏移= localInputStream.read(arrayOfByte))大于0)
        {
            localFileOutputStream.write(arrayOfByte,0,偏移量);
        }
        localFileOutputStream.close();
        localInputStream.close();
        Log.d(EPUB,文件名+复制到手机);
    }
    赶上(IOException异常localIOException)
    {
        localIOException.printStackTrace();
        Log.d(EPUB,无法复制);
        返回;
    }
}

公共无效copyFontToDevice(字符串文件名)
{
    尝试
    {
        字符串路径= this.getFilesDir()getAbsolutePath()+/书籍/字体/+文件名。
        档案文件=新的文件(路径);
        如果(file.exists())回报;
        InputStream的localInputStream = this.getAssets()开(字体/+文件名)。
        FileOutputStream中localFileOutputStream =新的FileOutputStream(this.getFilesDir()getAbsolutePath()+/书籍/字体/+文件名);

        byte []的arrayOfByte =新的字节[1024];
        INT抵消;
        而((偏移= localInputStream.read(arrayOfByte))大于0)
        {
            localFileOutputStream.write(arrayOfByte,0,偏移量);
        }
        localFileOutputStream.close();
        localInputStream.close();
        Log.d(EPUB,文件名+复制到手机);
    }
    赶上(IOException异常localIOException)
    {
        localIOException.printStackTrace();
        Log.d(EPUB,无法复制);
        返回;
    }
}

一流的ContentHandler实现ContentListener
{
    众长的getLength(字符串baseDirectory,字符串的contentPath)
    {
        字符串路径= baseDirectory +/+的contentPath;
        档案文件=新的文件(路径);
        如果(file.exists())
        {
            返回file.length();
        }
        其他
        {
            返回0;
        }
    }

    公共布尔isExists(字符串baseDirectory,字符串的contentPath)
    {
        字符串路径= baseDirectory +/+的contentPath;
        档案文件=新的文件(路径);
        布尔水库= FALSE;
        Log.w(EPUB的contentPath);
        如果(file.exists())
        {
            RES = TRUE;
        }
        其他
        {
            RES = FALSE;
        }
        返回水库;
    }

    公共调用long getLastModified(字符串baseDirectory,字符串的contentPath)
    {
        字符串路径= baseDirectory +/+的contentPath;
        档案文件=新的文件(路径);
        如果(file.exists())
        {
            返回file.lastModified();
        }
        其他
        {
            返回0;
        }
    }

    公众的InputStream的getInputStream(字符串baseDirectory,字符串的contentPath)
    {
        字符串路径= baseDirectory +/+的contentPath;
        档案文件=新的文件(路径);
        尝试
        {
            的FileInputStream FIS =新的FileInputStream(文件);
            返回FIS;
        }
        赶上(例外五)
        {
            返回null;
        }
    }
}
 

在logcat的为Android 2.3.5 - HTC茶茶

  8月1日至26日:40:04.180:我/的System.out(4980):绝对路径:/data/data/com.mehdok.epubtest/files
八月一日至26日:40:04.180:我/的System.out(4980):文件目录:/data/data/com.mehdok.epubtest/files
八月一日至26日:40:04.180:D / EPUB(4980):/data/data/com.mehdok.epubtest/files/scripts
八月一日至26日:40:04.180:D / EPUB(4980):/data/data/com.mehdok.epubtest/files/images
八月一日至26日:40:04.190:D / EPUB(4980):/data/data/com.mehdok.epubtest/files/covers
八月一日至26日:40:04.260:D / EPUB(4980):PagesCenter.png复制到手机
八月一日至26日:40:04.270:D / EPUB(4980):PagesStack.png复制到手机
八月一日至26日:40:04.270:D / EPUB(4980):/data/data/com.mehdok.epubtest/files/downloads
八月一日至26日:40:04.270:D / EPUB(4980):/data/data/com.mehdok.epubtest/files/books
八月一日至26日:40:04.330:D / EPUB(4980):/data/data/com.mehdok.epubtest/files/books/fonts
八月一日至26日:40:04.520:D / EPUB(4980):AliceinWonderland.epub复制到手机
八月一日至26日:40:04.520:D / szipinf(4980):初始化膨胀状态
八月一日至26日:40:04.520:D / szipinf(4980):初始化zlib的膨胀
八月一日至26日:40:04.991:D / EPUB(4980):arial.ttf复制到手机
八月一日至26日:40:04.991:D / szipinf(4980):初始化膨胀状态
八月一日至26日:40:04.991:D / szipinf(4980):初始化zlib的膨胀
八月一日至26日:40:05.071:D / EPUB(4980):simpo.ttf复制到手机
八月一日至26日:40:05.071:D / szipinf(4980):初始化膨胀状态
八月一日至26日:40:05.111:D / szipinf(4980):初始化zlib的膨胀
八月一日至26日:40:05.321:D / EPUB(4980):tahoma.ttf复制到手机
八月一日至26日:40:05.321:D / szipinf(4980):初始化膨胀状态
八月一日至26日:40:05.321:D / szipinf(4980):初始化zlib的膨胀
八月一日至26日:40:05.701:D / EPUB(4980):TIMES.TTF复制到手机
八月一日至26日:40:05.821:I / dalvikvm(4980):找不到方法android.view.Display.getRealMetrics,从方法com.skytree.epub.br.getRawHeight引用
八月一日至26日:40:05.821:W / dalvikvm(4980):VFY:无法解析虚方法4610:Landroid /查看/显示; .getRealMetrics(Landroid / UTIL / DisplayMetrics;)V
八月一日至26日:40:05.821:D / dalvikvm(4980):VFY:更换运code 0x6e在0x001a
八月一日至26日:40:05.831:D / dalvikvm(4980):VFY:死code 0x001d-0020在LCOM /晴空塔/ EPUB / BR; .getRawHeight()我
八月一日至26日:40:05.831:I / dalvikvm(4980):找不到方法android.view.Display.getRealMetrics,从方法引用com.skytree.epub.br.getRawWidth
八月一日至26日:40:05.831:W / dalvikvm(4980):VFY:无法解析虚方法4610:Landroid /查看/显示; .getRealMetrics(Landroid / UTIL / DisplayMetrics;)V
八月一日至26日:40:05.831:D / dalvikvm(4980):VFY:更换运code 0x6e在0x001a
八月一日至26日:40:05.831:D / dalvikvm(4980):VFY:死code 0x001d-0020在LCOM /晴空塔/ EPUB / BR; .getRawWidth()我
八月一日至26日:40:05.911:D /数据库(4980):dbopen():PATH = /data/data/com.mehdok.epubtest/databases/webview.db,标志= 6,不能与stat文件,错误号:2 ,消息:没有这样的文件或目录
八月一日至26日:40:05.911:D /数据库(4980):dbopen():PATH = /data/data/com.mehdok.epubtest/databases/webview.db,模式:删除,硬盘可用空间:26男,处理:0x267730
八月一日至26日:40:05.982:D /数据库(4980):dbopen():PATH = /data/data/com.mehdok.epubtest/databases/webviewCache.db,标志= 6,不能与stat文件,错误号:2 ,消息:没有这样的文件或目录
八月一日至26日:40:05.982:D /数据库(4980):dbopen():PATH = /data/data/com.mehdok.epubtest/databases/webviewCache.db,模式:删除,硬盘可用空间:26男,处理:0x283068
8月1号至26日:40:06.072:D / QCT(4980):[RequestQueue.ActivePool.ActivePool]≥>启用关机= FALSE
8月1号至26日:40:06.072:D / QCT(4980):[IdleCache.IdleCache]≥> IDLE_CACHE_MAX = 40
8月1号至26日:40:06.112:D / QCT(4980):[preConnectionManager preConnectionManager。]≥> TCP_ pre_CONNECT = FALSE
八月一日至26日:40:06.172:D / Skia的(4980):htcFlashPlugin :: htcFlashPlugin
8月1号至26日:40:06.172:D / QCT(4980):[WebView.WebView]≥>启用关机= FALSE
八月一日至26日:40:06.182:D / Skia的(4980):htcFlashPlugin :: htcFlashPlugin
8月1号至26日:40:06.182:D / QCT(4980):[WebView.WebView]≥>启用关机= FALSE
八月一日至26日:40:06.192:D / Skia的(4980):htcFlashPlugin :: htcFlashPlugin
8月1号至26日:40:06.192:D / QCT(4980):[WebView.WebView]≥>启用关机= FALSE
八月一日至26日:40:06.262:D / dalvikvm(4980):GC_EXTERNAL_ALLOC释放177K,43%免费3156K / 5447K,外部0K / 0K,暂停51ms
8月1号至26日:40:06.262:D / QCT(4980):[preConnectionManager preConnectionManager。]≥> TCP_ pre_CONNECT = FALSE
8月1号至26日:40:06.272:D / QCT(4980):[preConnectionManager preConnectionManager。]≥> TCP_ pre_CONNECT = FALSE
八月一日至26日:40:06.322:D / dalvikvm(4980):GC_EXTERNAL_ALLOC释放19K,42%免费3173K / 5447K,外部6K / 512K,暂停45ms
八月一日至26日:40:06.442:D / ATRecorder(4980):com.htc.autotest.dlib.RecordEngine装载机dalvik.system.DexClassLoader@40540e00
八月一日至26日:40:06.692:D / libEGL(4980):加载/system/lib/egl/libGLES_android.so
八月一日至26日:40:06.742:D / libEGL(4980):加载/system/lib/egl/libEGL_adreno200.so
八月一日至26日:40:06.832:D / libEGL(4980):加载/system/lib/egl/libGLESv1_CM_adreno200.so
八月一日至26日:40:06.832:D / libEGL(4980):加载/system/lib/egl/libGLESv2_adreno200.so
八月一日至26日:40:06.872:E /的Adreno200-ES20(4980):override1 = 0xfffffffe,override2 = 0xFFF的*
 

logcat的为Android 4.4 - 模拟器

  8月1日至26日:47:22.760:我/的System.out(1183):绝对路径:/data/data/com.mehdok.epubtest/files
八月一日至26日:47:22.760:我/的System.out(1183):文件目录:/data/data/com.mehdok.epubtest/files
八月一日至26日:47:22.770:D / EPUB(1183):/data/data/com.mehdok.epubtest/files/scripts
八月一日至26日:47:22.810:D / EPUB(1183):/data/data/com.mehdok.epubtest/files/images
八月一日至26日:47:22.810:D / EPUB(1183):/data/data/com.mehdok.epubtest/files/covers
八月一日至26日:47:22.900:D / EPUB(1183):PagesCenter.png复制到手机
八月一日至26日:47:22.940:D / EPUB(1183):PagesStack.png复制到手机
八月一日至26日:47:22.940:D / EPUB(1183):/data/data/com.mehdok.epubtest/files/downloads
八月一日至26日:47:22.960:D / EPUB(1183):/data/data/com.mehdok.epubtest/files/books
八月一日至26日:47:22.960:D / EPUB(1183):/data/data/com.mehdok.epubtest/files/books/fonts
八月一日至26日:47:23.090:D / EPUB(1183):AliceinWonderland.epub复制到手机
八月一日至26日:47:23.980:D / EPUB(1183):arial.ttf复制到手机
八月一日至26日:47:24.040:D / EPUB(1183):simpo.ttf复制到手机
八月一日至26日:47:24.320:D / EPUB(1183):tahoma.ttf复制到手机
八月一日至26日:47:24.670:D / EPUB(1183):TIMES.TTF复制到手机
八月一日至26日:47:24.850:V / WebViewChromium(1183):铬绑定到后台活套活套{b3d68530}
八月一日至26日:47:24.860:I /铬(1183):[INFO:library_loader_hooks.cc(112)]铬启用日志记录:级别= 0,默认的详细程度= 0
八月一日至26日:47:24.870:I / BrowserProcessMain(1183):初始化铬工艺,提炼= 0
八月一日至26日:47:25.010:W /铬(1183):警告:proxy_service.cc(888)PAC支持禁用,因为没有系统的实现
八月一日至26日:47:25.020:D /(1183):HostConnection ::得到()新主机连接建立0xb7b15d98,TID 1183
八月一日至26日:47:26.200:D / dalvikvm(1183):GC_FOR_ALLOC释放126K,7%免费2893K / 3104K,暂停49ms,共51ms
八月一日至26日:47:26.210:I / dalvikvm堆(1183):成长堆(破片的情况下),以3.509MB为635812字节分配
八月一日至26日:47:26.290:D / dalvikvm(1183):GC_FOR_ALLOC释放1K,6%免费3512K / 3728K,暂停74ms,共74ms
八月一日至26日:47:26.510:W / ContentSettingsAdapter(1183):setDefaultZoom不支持,变焦= FAR
八月一日至26日:47:26.560:W / ContentSettingsAdapter(1183):setDefaultZoom不支持,变焦= FAR
八月一日至26日:47:26.610:W / ContentSettingsAdapter(1183):setDefaultZoom不支持,变焦= FAR
八月一日至26日:47:26.820:D / dalvikvm(1183):GC_FOR_ALLOC释放33K,4%的自由3605K / 3728K,暂停为33ms,共34ms
八月一日至26日:47:26.830:I / dalvikvm堆(1183):成长堆(破片的情况下),以4.107MB为532496字节分配
八月一日至26日:47:26.910:D / dalvikvm(1183):GC_FOR_ALLOC释放< 1K,3%的自由4125K / 4252K,暂停73ms,共74ms
八月一日至26日:47:27.670:W / EGL_emulation(1183):eglSurfaceAttrib未实现
八月一日至26日:47:27.680:D / OpenGLRenderer(1183):启用调试模式0
八月一日至26日:47:27.970:D /(1183):HostConnection ::得到()新主机连接建立0xb7b38c40,TID 1211
八月一日至26日:47:28.070:W / AwContents(1183):nativeOnDraw失败;结算到背景颜色。
八月一日至26日:47:28.100:W / AwContents(1183):nativeOnDraw失败;结算到背景颜色。
八月一日至26日:47:28.100:W / AwContents(1183):nativeOnDraw失败;结算到背景颜色。
八月一日至26日:47:29.980:W / AwContents(1183):nativeOnDraw失败;结算到背景颜色。
八月一日至26日:47:29.990:W / AwContents(1183):nativeOnDraw失败;结算到背景颜色。
八月一日至26日:47:29.990:W / AwContents(1183):nativeOnDraw失败;结算到背景颜色。
八月一日至26日:47:30.910:I /编舞(1183):跳过54帧!该应用程序可能会做它的主线程的工作太多了。
八月一日至26日:47:30.910:W / AwContents(1183):nativeOnDraw失败;结算到背景颜色。
八月一日至26日:47:30.910:W / AwContents(1183):nativeOnDraw失败;结算到背景颜色。
 

单击后退按钮后,我得到这个logcat的

  8月1日至26日:41:52.646:D / AndroidRuntime(4980):关闭虚拟机
八月一日至26日:41:52.646:W / dalvikvm(4980):主题ID = 1:螺纹退出与未捕获的异常(组= 0x400205a0)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):致命异常:主要
八月一日至26日:41:52.666:E / AndroidRuntime(4980):显示java.lang.NullPointerException
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在com.skytree.epub.ec.b(来源不明)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在com.skytree.epub.br.m(来源不明)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在com.skytree.epub.br.onDetachedFromWindow(来源不明)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在android.view.View.dispatchDetachedFromWindow(View.java:6235)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1250)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1248)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1248)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1248)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1248)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在android.view.ViewRoot.dispatchDetachedFromWindow(ViewRoot.java:1862)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在android.view.ViewRoot.doDie(ViewRoot.java:2940)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在android.view.ViewRoot.die(ViewRoot.java:2910)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:254)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在android.view.Window $ LocalWindowManager.removeViewImmediate(Window.java:445)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3182)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在android.app.ActivityThread.access $ 2100(ActivityThread.java:132)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1071)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在android.os.Handler.dispatchMessage(Handler.java:99)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在android.os.Looper.loop(Looper.java:150)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在android.app.ActivityThread.main(ActivityThread.java:4293)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在java.lang.reflect.Method.invokeNative(本机方法)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在java.lang.reflect.Method.invoke(Method.java:507)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:839)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
八月一日至26日:41:52.666:E / AndroidRuntime(4980):在dalvik.system.NativeStart.main(本机方法)
 

解决方案

您只需要在你的基地目录解压您的EPUB书(在你的情况下,其/书籍/文件名)。 你要解压缩的epub文件中的书籍文件夹EPUB文件名。

您可以看到完整的演示,下面的链接

<一个href="http://www.skytree21.com/cgi-bin/download.php?os=android&version=3.9.8&type=core_sample">http://www.skytree21.com/cgi-bin/download.php?os=android&version=3.9.8&type=core_sample

在演示,在本地服务类,你会得到$ C $下解压缩文件。 在本演示中,他们已经下载EPUB文件从网页和下载第一次后,它被移动到下载文件夹中的电话簿,然后它得到解压缩到根目录书电话簿,然后skyepub SDK将直接采取通过设置setBaseDirectory它的路径。

下面是$ C $下解压缩文件的移动资产的文件,下载文件夹,电话目录之后

 公共无效unzipBook(字符串文件名){

        字符串TARGETDIR =新的String(getFilesDir()getAbsolutePath()+/书籍/+文件名。);
        TARGETDIR = SkyUtility.removeExtention(TARGETDIR);

        字符串文件路径=新的String(getFilesDir()getAbsolutePath()+/下载);
        解压缩解压缩=新解压缩(文件名,文件路径,TARGETDIR);
        unzip.addObserver(新UnzipHandler());
        unzip.unzip();
    }
    类UnzipHandler实现观测{
        @覆盖
        公共无效更新(可观察观察到,对象数据){
            //解压完成
            (新处理程序())。postDelayed(新可运行(){
                公共无效的run(){

                }
            },500);
        }
    }
 

在你的情况,你只需要把你的资产参考,并解压缩it.You'll获得成功。

I'm triyng to create an epub reader for android, so after a lot of searching I found skyepub library (SDK) . seems it have all features i want.

i followed the tut in the site, but after running the code i got a blank screen and different logcat for different apis, i checked the code again and agian but i can't find what is wrong.

here is my code and logcat, any help would be appreciated.

public void makeLayout()
{ 
    String fileName = new String();
    fileName = "AliceinWonderland.epub";
    makeSetup(); //making directory in device and copy every thing to it
    rv = new ReflowableControl(this); // rv is ReflowableControl. an epub class (view) for showing content
    Bitmap pageCenter = BitmapFactory.decodeFile(getFilesDir().getAbsolutePath() + "/images/PagesCenter.png");
    Bitmap pageStack = BitmapFactory.decodeFile(getFilesDir().getAbsolutePath() + "/images/PagesStack.png");

    rv.setPagesStackImage(pageStack);
    rv.setPagesCenterImage(pageCenter);
    rv.setBaseDirectory(getFilesDir() + "/books");
    rv.setBookName(fileName);

    rv.setDoublePagedForLandscape(true);
    rv.setFont("TimesRoman", 26);
    rv.setLineSpacing(135);
    rv.setHorizontalGapRatio(0.15);
    rv.setVerticalGapRatio(0.1);

    /*
     *  all listener class are implementation of default class in library with simple override method like
     *  public void onClick(int x,int y) 
     *   {
     *       Log.w("EPub","Click Detected at"+x+":"+y);
     *   }
     */

    rv.setHighlightListener(new HighlightDelegate());
    rv.setPageMovedListener(new PageMovedDelegate());
    rv.setSelectionListener(new SelectionDelegate());
    rv.setPagingListener(new PagingDelegate());
    rv.setSearchListener(new SearchDelegate());
    rv.setStateListener(new StateDelegate());
    rv.setClickListener(new ClickDelegate());
    rv.setBookmarkListener(new BookmarkDelegate());
    ContentHandler cl = new ContentHandler();
    rv.setContentListener(cl);

    rv.setStartPositionInBook(0.285714f);
    rv.setNavigationAreaWidthRatio(0.4f);

    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    params.width = LayoutParams.MATCH_PARENT;
    params.height = LayoutParams.MATCH_PARENT;
    rv.setLayoutParams(params);

    ePubView = new RelativeLayout(this);
    RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    ePubView.setLayoutParams(rlp);
    ePubView.addView(rv);

    setContentView(ePubView);
}

public void makeSetup() 
{
    if (this.isSetup()) return;
    if (!this.makeDirectory("scripts")) 
    {
        debug("faild to make scripts directory");
    }

    if (!this.makeDirectory("images")) 
    {
        debug("faild to make images directory");
    }

    if (!this.makeDirectory("covers")) 
    {
        debug("faild to make images directory");
    }

    copyImageToDevice("PagesCenter.png");
    copyImageToDevice("PagesStack.png");
    if (!this.makeDirectory("downloads")) 
    {
        debug("faild to make downloads directory");
    }

    if (!this.makeDirectory("books"))
    {
        debug("faild to make books directory");
    }

    if (!this.makeDirectory("books/fonts"))
    {
        debug("faild to make fonts directory");
    }

    copyBookToDevice("AliceinWonderland.epub");

    copyFontToDevice("arial.ttf");
    copyFontToDevice("simpo.ttf");
    copyFontToDevice("tahoma.ttf");
    copyFontToDevice("times.ttf");

    SharedPreferences pref = this.getSharedPreferences("EPubTest",0);
    SharedPreferences.Editor edit = pref.edit();

    edit.putBoolean("isSetup", true);        
    edit.commit();
}

private boolean isSetup() 
{
    SharedPreferences pref = this.getSharedPreferences("EPubTest",0);        
    return pref.getBoolean("isSetup",false);
}

public boolean makeDirectory(String dirName) 
{
    boolean res;        
    String filePath = new String(this.getFilesDir().getAbsolutePath() + "/"+dirName);
    debug(filePath);
    File file = new File(filePath);
    if (!file.exists()) {
        res = file.mkdirs();
    }else {
        res = false;        
    }
    return res; 
}

public void copyImageToDevice(String fileName) 
{                 
    try
    {
        String path = this.getFilesDir().getAbsolutePath() + "/images/"+fileName;
        File file = new File(path);
        if (file.exists()) return;
        InputStream localInputStream = this.getAssets().open("images/"+fileName);                 
        FileOutputStream localFileOutputStream = new FileOutputStream(this.getFilesDir().getAbsolutePath() + "/images/"+fileName);

        byte[] arrayOfByte = new byte[1024];
        int offset;
        while ((offset = localInputStream.read(arrayOfByte))>0)
        {
            localFileOutputStream.write(arrayOfByte, 0, offset);                  
        }
        localFileOutputStream.close();
        localInputStream.close();
        Log.d("EPub", fileName+" copied to phone");             
    }
    catch (IOException localIOException)
    {
        localIOException.printStackTrace();
        Log.d("EPub", "failed to copy");
        return;
    }
}

public void copyBookToDevice(String fileName) 
{                 
    try
    {
        String path = this.getFilesDir().getAbsolutePath() + "/books/"+fileName;
        File file = new File(path);
        if (file.exists()) return;
        InputStream localInputStream = this.getAssets().open("books/"+fileName);                  
        FileOutputStream localFileOutputStream = new FileOutputStream(this.getFilesDir().getAbsolutePath() + "/books/"+fileName);

        byte[] arrayOfByte = new byte[1024];
        int offset;
        while ((offset = localInputStream.read(arrayOfByte))>0)
        {
            localFileOutputStream.write(arrayOfByte, 0, offset);                  
        }
        localFileOutputStream.close();
        localInputStream.close();
        Log.d("EPub", fileName+" copied to phone");             
    }
    catch (IOException localIOException)
    {
        localIOException.printStackTrace();
        Log.d("EPub", "failed to copy");
        return;
    }
}

public void copyFontToDevice(String fileName) 
{                 
    try
    {
        String path = this.getFilesDir().getAbsolutePath() + "/books/fonts/"+fileName;
        File file = new File(path);
        if (file.exists()) return;
        InputStream localInputStream = this.getAssets().open("fonts/"+fileName);                  
        FileOutputStream localFileOutputStream = new FileOutputStream(this.getFilesDir().getAbsolutePath() + "/books/fonts/"+fileName);

        byte[] arrayOfByte = new byte[1024];
        int offset;
        while ((offset = localInputStream.read(arrayOfByte))>0)
        {
            localFileOutputStream.write(arrayOfByte, 0, offset);                  
        }
        localFileOutputStream.close();
        localInputStream.close();
        Log.d("epub", fileName+" copied to phone");             
    }
    catch (IOException localIOException)
    {
        localIOException.printStackTrace();
        Log.d("epub", "failed to copy");
        return;
    }
}

class ContentHandler implements ContentListener 
{
    public long getLength(String baseDirectory,String contentPath) 
    {
        String path = baseDirectory + "/" + contentPath;
        File file = new File(path);
        if (file.exists()) 
        {
            return file.length(); 
        }
        else 
        {
            return 0;
        }
    }

    public boolean isExists(String baseDirectory,String contentPath) 
    {       
        String path = baseDirectory +"/"+ contentPath;
        File file = new File(path);
        boolean res = false;
        Log.w("EPub",contentPath);
        if (file.exists()) 
        {
            res =  true;
        }
        else 
        {
            res =  false;
        }
        return res;     
    }

    public long getLastModified(String baseDirectory,String contentPath) 
    {
        String path = baseDirectory + "/" + contentPath;
        File file = new File(path);
        if (file.exists()) 
        {
            return file.lastModified();
        }
        else 
        {
            return 0;       
        }
    }

    public InputStream getInputStream(String baseDirectory,String contentPath) 
    {
        String path = baseDirectory + "/" + contentPath;
        File file = new File(path);
        try 
        {
            FileInputStream fis = new FileInputStream(file);
            return fis;
        }
        catch(Exception e) 
        {
            return null;
        }       
    }
}

the logcat for android 2.3.5 - HTC Chacha

01-26 08:40:04.180: I/System.out(4980): Absolute Path: /data/data/com.mehdok.epubtest/files
01-26 08:40:04.180: I/System.out(4980): File Dir: /data/data/com.mehdok.epubtest/files
01-26 08:40:04.180: D/EPub(4980): /data/data/com.mehdok.epubtest/files/scripts
01-26 08:40:04.180: D/EPub(4980): /data/data/com.mehdok.epubtest/files/images
01-26 08:40:04.190: D/EPub(4980): /data/data/com.mehdok.epubtest/files/covers
01-26 08:40:04.260: D/EPub(4980): PagesCenter.png copied to phone
01-26 08:40:04.270: D/EPub(4980): PagesStack.png copied to phone
01-26 08:40:04.270: D/EPub(4980): /data/data/com.mehdok.epubtest/files/downloads
01-26 08:40:04.270: D/EPub(4980): /data/data/com.mehdok.epubtest/files/books
01-26 08:40:04.330: D/EPub(4980): /data/data/com.mehdok.epubtest/files/books/fonts
01-26 08:40:04.520: D/EPub(4980): AliceinWonderland.epub copied to phone
01-26 08:40:04.520: D/szipinf(4980): Initializing inflate state
01-26 08:40:04.520: D/szipinf(4980): Initializing zlib to inflate
01-26 08:40:04.991: D/epub(4980): arial.ttf copied to phone
01-26 08:40:04.991: D/szipinf(4980): Initializing inflate state
01-26 08:40:04.991: D/szipinf(4980): Initializing zlib to inflate
01-26 08:40:05.071: D/epub(4980): simpo.ttf copied to phone
01-26 08:40:05.071: D/szipinf(4980): Initializing inflate state
01-26 08:40:05.111: D/szipinf(4980): Initializing zlib to inflate
01-26 08:40:05.321: D/epub(4980): tahoma.ttf copied to phone
01-26 08:40:05.321: D/szipinf(4980): Initializing inflate state
01-26 08:40:05.321: D/szipinf(4980): Initializing zlib to inflate
01-26 08:40:05.701: D/epub(4980): times.ttf copied to phone
01-26 08:40:05.821: I/dalvikvm(4980): Could not find method android.view.Display.getRealMetrics, referenced from method com.skytree.epub.br.getRawHeight
01-26 08:40:05.821: W/dalvikvm(4980): VFY: unable to resolve virtual method 4610: Landroid/view/Display;.getRealMetrics (Landroid/util/DisplayMetrics;)V
01-26 08:40:05.821: D/dalvikvm(4980): VFY: replacing opcode 0x6e at 0x001a
01-26 08:40:05.831: D/dalvikvm(4980): VFY: dead code 0x001d-0020 in Lcom/skytree/epub/br;.getRawHeight ()I
01-26 08:40:05.831: I/dalvikvm(4980): Could not find method android.view.Display.getRealMetrics, referenced from method com.skytree.epub.br.getRawWidth
01-26 08:40:05.831: W/dalvikvm(4980): VFY: unable to resolve virtual method 4610: Landroid/view/Display;.getRealMetrics (Landroid/util/DisplayMetrics;)V
01-26 08:40:05.831: D/dalvikvm(4980): VFY: replacing opcode 0x6e at 0x001a
01-26 08:40:05.831: D/dalvikvm(4980): VFY: dead code 0x001d-0020 in Lcom/skytree/epub/br;.getRawWidth ()I
01-26 08:40:05.911: D/Database(4980): dbopen(): path = /data/data/com.mehdok.epubtest/databases/webview.db, flag = 6, cannot stat file, errno: 2,message: No such file or directory
01-26 08:40:05.911: D/Database(4980): dbopen(): path = /data/data/com.mehdok.epubtest/databases/webview.db, mode: delete, disk free size: 26 M, handle: 0x267730
01-26 08:40:05.982: D/Database(4980): dbopen(): path = /data/data/com.mehdok.epubtest/databases/webviewCache.db, flag = 6, cannot stat file, errno: 2,message: No such file or directory
01-26 08:40:05.982: D/Database(4980): dbopen(): path = /data/data/com.mehdok.epubtest/databases/webviewCache.db, mode: delete, disk free size: 26 M, handle: 0x283068
01-26 08:40:06.072: D/qct(4980): [RequestQueue.ActivePool.ActivePool] >> Enable Shutdown = false
01-26 08:40:06.072: D/qct(4980): [IdleCache.IdleCache] >> IDLE_CACHE_MAX = 40
01-26 08:40:06.112: D/qct(4980): [PreConnectionManager.PreConnectionManager] >> TCP_PRE_CONNECT = false
01-26 08:40:06.172: D/skia(4980): htcFlashPlugin::htcFlashPlugin
01-26 08:40:06.172: D/qct(4980): [WebView.WebView] >> Enable Shutdown = false
01-26 08:40:06.182: D/skia(4980): htcFlashPlugin::htcFlashPlugin
01-26 08:40:06.182: D/qct(4980): [WebView.WebView] >> Enable Shutdown = false
01-26 08:40:06.192: D/skia(4980): htcFlashPlugin::htcFlashPlugin
01-26 08:40:06.192: D/qct(4980): [WebView.WebView] >> Enable Shutdown = false
01-26 08:40:06.262: D/dalvikvm(4980): GC_EXTERNAL_ALLOC freed 177K, 43% free 3156K/5447K, external 0K/0K, paused 51ms
01-26 08:40:06.262: D/qct(4980): [PreConnectionManager.PreConnectionManager] >> TCP_PRE_CONNECT = false
01-26 08:40:06.272: D/qct(4980): [PreConnectionManager.PreConnectionManager] >> TCP_PRE_CONNECT = false
01-26 08:40:06.322: D/dalvikvm(4980): GC_EXTERNAL_ALLOC freed 19K, 42% free 3173K/5447K, external 6K/512K, paused 45ms
01-26 08:40:06.442: D/ATRecorder(4980): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@40540e00
01-26 08:40:06.692: D/libEGL(4980): loaded /system/lib/egl/libGLES_android.so
01-26 08:40:06.742: D/libEGL(4980): loaded /system/lib/egl/libEGL_adreno200.so
01-26 08:40:06.832: D/libEGL(4980): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
01-26 08:40:06.832: D/libEGL(4980): loaded /system/lib/egl/libGLESv2_adreno200.so
01-26 08:40:06.872: E/Adreno200-ES20(4980): override1= 0xfffffffe, override2= 0xfff *

logcat for android 4.4 - emulator

01-26 08:47:22.760: I/System.out(1183): Absolute Path: /data/data/com.mehdok.epubtest/files
01-26 08:47:22.760: I/System.out(1183): File Dir: /data/data/com.mehdok.epubtest/files
01-26 08:47:22.770: D/EPub(1183): /data/data/com.mehdok.epubtest/files/scripts
01-26 08:47:22.810: D/EPub(1183): /data/data/com.mehdok.epubtest/files/images
01-26 08:47:22.810: D/EPub(1183): /data/data/com.mehdok.epubtest/files/covers
01-26 08:47:22.900: D/EPub(1183): PagesCenter.png copied to phone
01-26 08:47:22.940: D/EPub(1183): PagesStack.png copied to phone
01-26 08:47:22.940: D/EPub(1183): /data/data/com.mehdok.epubtest/files/downloads
01-26 08:47:22.960: D/EPub(1183): /data/data/com.mehdok.epubtest/files/books
01-26 08:47:22.960: D/EPub(1183): /data/data/com.mehdok.epubtest/files/books/fonts
01-26 08:47:23.090: D/EPub(1183): AliceinWonderland.epub copied to phone
01-26 08:47:23.980: D/epub(1183): arial.ttf copied to phone
01-26 08:47:24.040: D/epub(1183): simpo.ttf copied to phone
01-26 08:47:24.320: D/epub(1183): tahoma.ttf copied to phone
01-26 08:47:24.670: D/epub(1183): times.ttf copied to phone
01-26 08:47:24.850: V/WebViewChromium(1183): Binding Chromium to the background looper Looper{b3d68530}
01-26 08:47:24.860: I/chromium(1183): [INFO:library_loader_hooks.cc(112)] Chromium logging enabled: level = 0, default verbosity = 0
01-26 08:47:24.870: I/BrowserProcessMain(1183): Initializing chromium process, renderers=0
01-26 08:47:25.010: W/chromium(1183): [WARNING:proxy_service.cc(888)] PAC support disabled because there is no system implementation
01-26 08:47:25.020: D/(1183): HostConnection::get() New Host Connection established 0xb7b15d98, tid 1183
01-26 08:47:26.200: D/dalvikvm(1183): GC_FOR_ALLOC freed 126K, 7% free 2893K/3104K, paused 49ms, total 51ms
01-26 08:47:26.210: I/dalvikvm-heap(1183): Grow heap (frag case) to 3.509MB for 635812-byte allocation
01-26 08:47:26.290: D/dalvikvm(1183): GC_FOR_ALLOC freed 1K, 6% free 3512K/3728K, paused 74ms, total 74ms
01-26 08:47:26.510: W/ContentSettingsAdapter(1183): setDefaultZoom not supported, zoom=FAR
01-26 08:47:26.560: W/ContentSettingsAdapter(1183): setDefaultZoom not supported, zoom=FAR
01-26 08:47:26.610: W/ContentSettingsAdapter(1183): setDefaultZoom not supported, zoom=FAR
01-26 08:47:26.820: D/dalvikvm(1183): GC_FOR_ALLOC freed 33K, 4% free 3605K/3728K, paused 33ms, total 34ms
01-26 08:47:26.830: I/dalvikvm-heap(1183): Grow heap (frag case) to 4.107MB for 532496-byte allocation
01-26 08:47:26.910: D/dalvikvm(1183): GC_FOR_ALLOC freed <1K, 3% free 4125K/4252K, paused 73ms, total 74ms
01-26 08:47:27.670: W/EGL_emulation(1183): eglSurfaceAttrib not implemented
01-26 08:47:27.680: D/OpenGLRenderer(1183): Enabling debug mode 0
01-26 08:47:27.970: D/(1183): HostConnection::get() New Host Connection established 0xb7b38c40, tid 1211
01-26 08:47:28.070: W/AwContents(1183): nativeOnDraw failed; clearing to background color.
01-26 08:47:28.100: W/AwContents(1183): nativeOnDraw failed; clearing to background color.
01-26 08:47:28.100: W/AwContents(1183): nativeOnDraw failed; clearing to background color.
01-26 08:47:29.980: W/AwContents(1183): nativeOnDraw failed; clearing to background color.
01-26 08:47:29.990: W/AwContents(1183): nativeOnDraw failed; clearing to background color.
01-26 08:47:29.990: W/AwContents(1183): nativeOnDraw failed; clearing to background color.
01-26 08:47:30.910: I/Choreographer(1183): Skipped 54 frames!  The application may be doing too much work on its main thread.
01-26 08:47:30.910: W/AwContents(1183): nativeOnDraw failed; clearing to background color.
01-26 08:47:30.910: W/AwContents(1183): nativeOnDraw failed; clearing to background color.

after clicking back button i got this logcat

01-26 08:41:52.646: D/AndroidRuntime(4980): Shutting down VM
01-26 08:41:52.646: W/dalvikvm(4980): threadid=1: thread exiting with uncaught exception (group=0x400205a0)
01-26 08:41:52.666: E/AndroidRuntime(4980): FATAL EXCEPTION: main
01-26 08:41:52.666: E/AndroidRuntime(4980): java.lang.NullPointerException
01-26 08:41:52.666: E/AndroidRuntime(4980):     at com.skytree.epub.ec.b(Unknown Source)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at com.skytree.epub.br.m(Unknown Source)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at com.skytree.epub.br.onDetachedFromWindow(Unknown Source)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at android.view.View.dispatchDetachedFromWindow(View.java:6235)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1250)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1248)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1248)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1248)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1248)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at android.view.ViewRoot.dispatchDetachedFromWindow(ViewRoot.java:1862)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at android.view.ViewRoot.doDie(ViewRoot.java:2940)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at android.view.ViewRoot.die(ViewRoot.java:2910)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:254)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at android.view.Window$LocalWindowManager.removeViewImmediate(Window.java:445)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3182)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at android.app.ActivityThread.access$2100(ActivityThread.java:132)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1071)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at android.os.Looper.loop(Looper.java:150)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at android.app.ActivityThread.main(ActivityThread.java:4293)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at java.lang.reflect.Method.invokeNative(Native Method)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at java.lang.reflect.Method.invoke(Method.java:507)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-26 08:41:52.666: E/AndroidRuntime(4980):     at dalvik.system.NativeStart.main(Native Method)

解决方案

You just need to unzip your epub book at your base directory (in your case its /book/filename). You have to unzip the epub file in books folder as epub file name.

You can see the full demo to below link

http://www.skytree21.com/cgi-bin/download.php?os=android&version=3.9.8&type=core_sample

in Demo,in LocalService class you'll get code for unzip file. In this demo they have downloaded epub file from web and after downloading first it is moved to download folder in phone directory and then its get extracted to base directory books in phone directory and then skyepub SDK will directly take its path by setting setBaseDirectory.

Here is the code for unzip file after moving asset file to download folder to phone directory

public void unzipBook(String fileName) {

        String targetDir = new String(getFilesDir().getAbsolutePath() + "/books/" + fileName);
        targetDir = SkyUtility.removeExtention(targetDir);

        String filePath = new String(getFilesDir().getAbsolutePath() + "/downloads");
        Unzip unzip = new Unzip(fileName, filePath, targetDir);
        unzip.addObserver(new UnzipHandler());
        unzip.unzip();      
    }
    class UnzipHandler implements Observer {
        @Override
        public void update(Observable observable, Object data) {
            //Unzip completed
            (new Handler()).postDelayed(new Runnable() {
                public void run() {

                }
            },500);     
        }       
    }

In your case you just need to take your asset reference and unzip it.You'll get success.

这篇关于Android的EPUB库,skyepub的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆