Android epub 库、skyepub

2024-01-29

我正在尝试为 android 创建一个 epub 阅读器,所以经过大量搜索后我找到了 skyepub 库 (SDK) 。似乎它有我想要的所有功能。

我按照网站上的教程进行操作,但是运行代码后我得到了黑屏不同的 api 有不同的 logcat,我再次检查了代码,但我找不到问题所在。

这是我的代码和 logcat,任何帮助将不胜感激。

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;
        }       
    }
}

android 2.3.5 的 logcat - 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 *

适用于 android 4.4 的 logcat - 模拟器

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.

单击后退按钮后我得到了这个 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)

您只需将 epub 书解压到您的基本目录(在您的情况下为 /book/filename)。 您必须将书籍文件夹中的 epub 文件解压为 epub 文件名。

您可以在下面的链接中查看完整的演示

在演示中,在 LocalService 类中,您将获得解压缩文件的代码。 在这个演示中,他们从网络下载了 epub 文件,下载后首先将其移动到手机目录中的下载文件夹,然后将其解压到手机目录中的基本目录 books 中,然后 skyepub SDK 将通过设置 setBaseDirectory 直接获取其路径。

这是将资产文件移动到下载文件夹到手机目录后解压缩文件的代码

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);     
        }       
    }

在您的情况下,您只需获取资产参考并将其解压缩。您就会成功。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android epub 库、skyepub 的相关文章

  • 在名称中使用时间戳时,Android Studio 在构建后无法启动应用程序

    我遇到了 gradle 和 Android Studio 的问题 该问题仅在 Android Studio 中构建时出现 BuildServer 和 Commandline 工作正常 applicationVariants all vari
  • startActivity overridePendingTransition 只显示进入动画

    基本上 我遇到的问题是只显示输入幻灯片动画 调用 Activity 不会产生动画 startActivity intent overridePendingTransition R anim right in partly R anim le
  • 添加动态数据时 footable 出现问题

    我需要 jQuery Mobile 方面的一些帮助富表 http css tricks com footable a jquery plugin for responsive data tables 我正在表中动态添加数据 HTML tab
  • Android ListView 自定义适配器 ImageButton

    这可能不是正确的方法 如果有更好的方法请告诉我 我创建了一个自定义适配器类 在我的 getView 方法中我膨胀了我想要使用的视图 public View getView int position View convertView View
  • Android 5.0 Lollipop 中屏幕固定关闭时如何收到通知?

    我有一个在后台运行的应用程序 并在手机上发生特定事件时启动活动 我发现在 Android 5 0 中 当用户使用另一个应用程序打开屏幕固定时 startActivity intent 调用将被完全忽略 我的应用程序不知道该活动尚未启动 因此
  • ListView:防止视图回收

    我有一个使用回收视图的 ListView 我试图阻止视图被回收 所以我使用 setHasTransientState android support v4 view ViewCompatJB setHasTransientState Vie
  • 游标索引越界异常

    打开后出现光标索引越界错误 数据库 请任何人告诉我如何打开现有数据库 sqllite Android 我想在数据库上触发一个选择查询 检索一些信息 public void getPatient SQLiteDatabase db Strin
  • Android CursorAdapter、ListView 和后台线程

    我一直在开发的这个应用程序有包含数兆字节数据的数据库可供筛选 许多活动只是列表视图 通过数据库中的各个级别的数据下降 直到到达 文档 即从数据库中提取并显示在手机上的 HTML 我遇到的问题是 其中一些活动需要能够通过捕获击键并重新运行带有
  • Android 8.1 中 Activity 自行旋转并恢复正常

    我的应用程序在所有 Android 版本上运行良好 但我注意到在 Android 8 1 0 Oreo 中 当我将屏幕从纵向活动转到横向活动时 以及当我按后退按钮时 它会显示异常行为 屏幕自动从横向旋转并恢复正常 看起来 Activity
  • Android 谷歌地图 V2 已停止

    我正在尝试构建地图应用程序并关注这个链接 https blog emildesign rhcloud com p 435一步步 我在这里找到了类似的主题 但对我没有帮助 我想显示地图 但是当我运行它时 它返回强制关闭和我的 Android
  • 使用 mupdf android 库导航到特定页面

    我如何使用 muPDF 库导航到特定页面 或者有没有办法让图书馆不记得我最后在那个pdf文件中浏览的是哪一页 Uri uri Uri parse path Intent intent new Intent MainActivity getC
  • 如何在android中画一条曲线?

    我是 Android 新手 正在开发一个关于绘制线条的示例项目 我想画一条连接两点的曲线或高架线 x1 y1 and x2 y2 我试过canvas drawArc 方法 但是RectF内的值drawArc方法只是圆的 x y 中心点 它在
  • android 多关键词搜索

    我的应用程序包含搜索功能 它将搜索数据库内的内容 我的搜索的弱点是 我只能使用一个标签进行搜索 例如我只能搜索 猫 它会返回我的数据库中包含 猫 一词的内容 因为我正在使用LIKE在 select 语句期间进行查询 如何使用多个标签进行搜索
  • Android httpclient文件上传数据损坏和超时问题

    我在 Android 中上传图像时遇到问题 我正在使用 apache httpmime 4 1 lib 代码是这样的 MultipartEntity reqEntity new MultipartEntity HttpMultipartMo
  • Android Drawable 绘图性能?

    在我看来 我有一个简单的 ARGB 可绘制对象 大约需要 2 毫秒才能绘制 但我可以在 0 5 毫秒内绘制与位图相同的文件 只是一些快速代码 我真的不能认为它是一个选项 优化可绘制对象的绘制速度的最佳方法是什么 这取决于可绘制的数量以及每个
  • 如何更改 Android 12 启动屏幕中的图标形状?

    我想要矩形形状的启动屏幕图标 而不是 android 12 中的圆形形状 我不相信你可以 如果你看这里的第 3 点 https developer android com about versions 12 features splash
  • 如何在 onDraw() 方法中定义与像素无关的高度

    我扩展了 View 来构建自定义小部件 我想用独立的像素单位定义小部件的高度 我认为可以通过将像素密度乘以所需的高度来完成 但我不知道该怎么做 到目前为止我所拥有的 最小化 public class Timeline extends Vie
  • 将 Crashlytics 集成到图书馆项目

    我有一个图书馆项目 自定义视图库项目 它没有任何活动 服务 我想将 Crashlytics SDK 集成到我的库中 当我尝试通过 Android Studio 的 Crashlytics 插件 工具栏中的图标 添加它时 它只是停留在 Che
  • Application.onLowMemory() 未调用

    我创建了自己的应用程序类 我尝试调试它 代码在 Application onCreate 处停止 但不会在 onLowMemory 处停止 为了测试该场景 我打开了许多其他高内存应用程序 我看到的是调试会话终止 在 Eclipse 中 并且
  • Android Espresso - 如果未选中,请单击复选框

    I have onView withId R id check box perform click 但我只想在尚未选中该复选框时执行此操作 我怎样才能在浓缩咖啡中做到这一点 我还想根据其之前的状态来切换复选框 开关 起初 我尝试用此方法打开

随机推荐