实施Android Pdf查看器库

jlo*_*pez 6 android pdf-viewer

似乎它是唯一不依赖于MuPDF的免费android的pdf阅读器.

我试图证明它,我已经下载了项目,但是为了运行它,我得到了例外:

01-17 13:45:03.960: E/AndroidRuntime(13631): FATAL EXCEPTION: main
01-17 13:45:03.960: E/AndroidRuntime(13631): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{net.sf.andpdf.pdfviewer/net.sf.andpdf.pdfviewer.PdfViewerActivity}: java.lang.InstantiationException: can't instantiate class net.sf.andpdf.pdfviewer.PdfViewerActivity
01-17 13:45:03.960: E/AndroidRuntime(13631):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1894)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at android.app.ActivityThread.access$600(ActivityThread.java:128)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at android.os.Handler.dispatchMessage(Handler.java:99)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at android.os.Looper.loop(Looper.java:137)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at android.app.ActivityThread.main(ActivityThread.java:4514)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at java.lang.reflect.Method.invokeNative(Native Method)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at java.lang.reflect.Method.invoke(Method.java:511)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at dalvik.system.NativeStart.main(Native Method)
01-17 13:45:03.960: E/AndroidRuntime(13631): Caused by: java.lang.InstantiationException: can't instantiate class net.sf.andpdf.pdfviewer.PdfViewerActivity
01-17 13:45:03.960: E/AndroidRuntime(13631):    at java.lang.Class.newInstanceImpl(Native Method)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at java.lang.Class.newInstance(Class.java:1319)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at android.app.Instrumentation.newActivity(Instrumentation.java:1027)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1885)
Run Code Online (Sandbox Code Playgroud)

在自述项目的自述文件中,最后一步我无法理解.

6)使用以下代码调用派生的PdfViewActivity:

 Intent intent = new Intent(this, YourPdfViewerActivity.class);
 intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, "PATH TO PDF GOES HERE");
 startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

谁能解释一下这一步呢?或者更重要的是:有人能够使用这个PDF阅读器吗?

谢谢

Ang*_*elo 7

问题是PdfViewerActivity你试图在你的实例化中Intent是一个abstract class并且无法实例化(这里的类的链接).您需要创建一个Activity,它扩展PdfViewerActivity实现该类具有的任何抽象方法.像这样的东西:

public class MyPdfViewerActivity extends PdfViewerActivity {

   //Your implementation code here.
}
Run Code Online (Sandbox Code Playgroud)