Question

I want to add MUPDF sources to my project and show pdfs on my app.

I do all these steps in the link below

 http://mupdf.blogspot.com/

And after added the classes into project like written here

 http://pastebin.com/YzHUhzE7

Now I want to show a pdf file in an activity on my app

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

But I get these errors from the 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

And here is my app's AndroidManifest.xml tag:

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

What can be the problem? How can I solve it?

Was it helpful?

Solution

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?

Double check the manifest file and declare it the activity / fix it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top