6

它似乎是唯一不依赖于 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)

在项目的自述文件中,最后一步我看不懂。

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

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

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

谢谢

4

1 回答 1

7

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

public class MyPdfViewerActivity extends PdfViewerActivity {

   //Your implementation code here.
}
于 2013-01-28T13:04:20.723 回答