gpt4 book ai didi

java - Android MuPDF 错误

转载 作者:行者123 更新时间:2023-11-30 09:20:31 29 4
gpt4 key购买 nike

我想将 MUPDF 源添加到我的项目并在我的应用程序上显示 pdf。

我在下面的链接中执行了所有这些步骤

 http://mupdf.blogspot.com/

然后像这里写的那样将类添加到项目中

 http://pastebin.com/YzHUhzE7

现在我想在我的应用程序的 Activity 中显示一个 pdf 文件

    Uri uri = Uri.parse("/storage/sdcard0/A.pdf");

Intent intent = new Intent(this, MuPDFActivity.class);

intent.setAction(Intent.ACTION_VIEW);

intent.setData(uri);

this.startActivity(intent);

但是我从 LogCat 得到了这些错误

     06-27 16:14:12.872: E/AndroidRuntime(13161): FATAL EXCEPTION: main
06-27 16:14:12.872: E/AndroidRuntime(13161): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.andpdfviewer/com.example.andpdfviewer.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.andpdfviewer/com.artifex.mupdfdemo.MuPDFActivity}; have you declared this activity in your AndroidManifest.xml?
06-27 16:14:12.872: E/AndroidRuntime(13161): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
06-27 16:14:12.872: E/AndroidRuntime(13161): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
06-27 16:14:12.872: E/AndroidRuntime(13161): at android.app.ActivityThread.access$700(ActivityThread.java:140)
06-27 16:14:12.872: E/AndroidRuntime(13161): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
06-27 16:14:12.872: E/AndroidRuntime(13161): at android.os.Handler.dispatchMessage(Handler.java:99)
06-27 16:14:12.872: E/AndroidRuntime(13161): at android.os.Looper.loop(Looper.java:137)
06-27 16:14:12.872: E/AndroidRuntime(13161): at android.app.ActivityThread.main(ActivityThread.java:4921)
06-27 16:14:12.872: E/AndroidRuntime(13161): at java.lang.reflect.Method.invokeNative(Native Method)
06-27 16:14:12.872: E/AndroidRuntime(13161): at java.lang.reflect.Method.invoke(Method.java:511)
06-27 16:14:12.872: E/AndroidRuntime(13161): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
06-27 16:14:12.872: E/AndroidRuntime(13161): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
06-27 16:14:12.872: E/AndroidRuntime(13161): at dalvik.system.NativeStart.main(Native Method)
06-27 16:14:12.872: E/AndroidRuntime(13161): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.andpdfviewer/com.artifex.mupdfdemo.MuPDFActivity}; have you declared this activity in your AndroidManifest.xml?
06-27 16:14:12.872: E/AndroidRuntime(13161): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1556)
06-27 16:14:12.872: E/AndroidRuntime(13161): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1431)
06-27 16:14:12.872: E/AndroidRuntime(13161): at android.app.Activity.startActivityForResult(Activity.java:3428)
06-27 16:14:12.872: E/AndroidRuntime(13161): at android.app.Activity.startActivityForResult(Activity.java:3389)
06-27 16:14:12.872: E/AndroidRuntime(13161): at android.app.Activity.startActivity(Activity.java:3599)
06-27 16:14:12.872: E/AndroidRuntime(13161): at android.app.Activity.startActivity(Activity.java:3567)
06-27 16:14:12.872: E/AndroidRuntime(13161): at com.example.andpdfviewer.MainActivity.onCreate(MainActivity.java:26)
06-27 16:14:12.872: E/AndroidRuntime(13161): at android.app.Activity.performCreate(Activity.java:5188)
06-27 16:14:12.872: E/AndroidRuntime(13161): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
06-27 16:14:12.872: E/AndroidRuntime(13161): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
06-27 16:14:12.872: E/AndroidRuntime(13161): ... 11 more

这是我应用的 AndroidManifest.xml 标签:

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.andpdfviewer.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name="com.artifex.mupdf.MuPDFActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="application/vnd.ms-xpsdocument"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="application/pdf"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="application/x-cbz"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="file"/>
<data android:mimeType="*/*"/>
<data android:pathPattern=".*\\.xps"/>
<data android:host="*"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="file"/>
<data android:mimeType="*/*"/>
<data android:pathPattern=".*\\.pdf"/>
<data android:host="*"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="file"/>
<data android:mimeType="*/*"/>
<data android:pathPattern=".*\\.cbz"/>
<data android:host="*"/>
</intent-filter>
</activity>
<activity android:name="OutlineActivity"
android:label="@string/outline_title">
</activity>
</application>

可能是什么问题?我该如何解决?

最佳答案

Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.andpdfviewer/com.artifex.mupdfdemo.MuPDFActivity}; have you declared this activity in your AndroidManifest.xml?

仔细检查 list 文件并将其声明为 Activity/修复它。

关于java - Android MuPDF 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17344400/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com