我想将 MuPDF 类添加到我的 android 项目中。我 成功地完成了链接中的所有事情。我将所有文件从/mupdf-source/android/
.
在我将 MuPDFActivity 添加到我的 Manifest.xml 之后。
<activity
android:name="com.artifex.mupdfdemo.MuPDFActivity"
android:screenOrientation="landscape">
</activity>
要打开 MuPDFActivity,我使用此代码。
Uri uri = Uri.parse("/storage/sdcard0/file.pdf");
Intent intent = new Intent(CarDetail.this,MuPDFActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.setData(uri);
startActivity(intent);
但是当我运行代码时,我从 LogCat 得到这些错误
07-08 13:52:03.137: E/AndroidRuntime(16925): FATAL EXCEPTION: main
07-08 13:52:03.137: E/AndroidRuntime(16925): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.artechin.mbtkatalog/com.artifex.mupdfdemo.MuPDFActivity}: java.lang.NullPointerException
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.app.ActivityThread.access$700(ActivityThread.java:140)
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.os.Handler.dispatchMessage(Handler.java:99)
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.os.Looper.loop(Looper.java:137)
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.app.ActivityThread.main(ActivityThread.java:4921)
07-08 13:52:03.137: E/AndroidRuntime(16925): at java.lang.reflect.Method.invokeNative(Native Method)
07-08 13:52:03.137: E/AndroidRuntime(16925): at java.lang.reflect.Method.invoke(Method.java:511)
07-08 13:52:03.137: E/AndroidRuntime(16925): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
07-08 13:52:03.137: E/AndroidRuntime(16925): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
07-08 13:52:03.137: E/AndroidRuntime(16925): at dalvik.system.NativeStart.main(Native Method)
07-08 13:52:03.137: E/AndroidRuntime(16925): Caused by: java.lang.NullPointerException
07-08 13:52:03.137: E/AndroidRuntime(16925): at com.artifex.mupdfdemo.MuPDFActivity.makeButtonsView(MuPDFActivity.java:835)
07-08 13:52:03.137: E/AndroidRuntime(16925): at com.artifex.mupdfdemo.MuPDFActivity.createUI(MuPDFActivity.java:416)
07-08 13:52:03.137: E/AndroidRuntime(16925): at com.artifex.mupdfdemo.MuPDFActivity.onCreate(MuPDFActivity.java:337)
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.app.Activity.performCreate(Activity.java:5188)
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
07-08 13:52:03.137: E/AndroidRuntime(16925): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
07-08 13:52:03.137: E/AndroidRuntime(16925): ... 11 more
可能是什么问题?我该如何解决?