2

I am using MuPDF as a library project.It has a package under src called com.artifex.mupdf. I want to call an activity called MuPDFActivity from said package from my main project. I tried Declaring the activity in my project's manifest like this :

          <activity android:name="com.artifex.mupdf.MuPDFActivity" 
          android:screenOrientation="portrait"
          android:theme="@style/Theme.Transparent" />

But I get the error "Have you declared the activity in ......".

I tried reading other Answers, but I was unable to get this to run.

I am calling the activity like this :

     Uri uri = Uri.parse("file:///mnt/sdcard/THIS .pdf");
     Intent intent = new Intent(getApplicationContext(), MuPDFActivity.class);
     intent.setAction(Intent.ACTION_VIEW);
     intent.setData(uri);
     startActivity(intent);

What am I doing wrong ? I have marks the library as a library project and I have added it in my main project too.

::EDIT::

This is my library project's manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.artifex.mupdf"
      android:versionCode="1"
      android:versionName="1.1">
    <supports-screens android:smallScreens="true"
                      android:normalScreens="true"
                      android:largeScreens="true"
                      android:anyDensity="true" />
    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="11"/>
    <application android:label="@string/app_name"
                 android:icon="@drawable/icon"
                 android:debuggable="true"
                 android:hardwareAccelerated="true">
        <activity android:name="ChoosePDFActivity"
                  android:label="@string/picker_title">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    <activity android:name="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>
</manifest> 

and this is my main project's manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mainpackage"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="17" />

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

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

            android:label="@string/title_activity_chap_gen_physics"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.mainpackage.ChapGenChemistry"
            android:screenOrientation="portrait"
            android:label="@string/title_activity_chap_gen_chemistry" >
        </activity>
        <activity
            android:name="com.mainpackage.ChapGenMaths"
           android:screenOrientation="portrait"
            android:label="@string/title_activity_chap_gen_maths" >
        </activity>
        <activity
            android:name="com.mainpackage.NcertPhysics"
          android:screenOrientation="portrait"
            android:label="@string/title_activity_ncert_physics" >
        </activity>
        <activity
            android:name="com.mainpackage.NcertChem"
             android:screenOrientation="portrait"
            android:label="@string/title_activity_ncert_chem" >
        </activity>
        <activity
            android:name="com.mainpackage.NcertMaths"
              android:screenOrientation="portrait"
            android:label="@string/title_activity_ncert_maths" >
        </activity>



        <activity android:name="ActionsActivityChapGen" 
              android:screenOrientation="portrait"
              android:theme="@style/Theme.Transparent" />
          <activity android:name="ActionsActivityNcert" 
                android:screenOrientation="portrait"
                android:theme="@style/Theme.Transparent" />



    </application>

</manifest>
harveyslash
  • 5,906
  • 12
  • 58
  • 111
  • post all your manifest – Rod_Algonquin Jun 15 '14 at 06:14
  • done that, please see edit now. – harveyslash Jun 15 '14 at 06:35
  • try using MyActivity.this or getActiity() for fragment I used a way similar to yours in my project and it worked for me a point to note is that you should not declare any class with name MuPDFActivity in your src folder also check that you have support library and others properly configured. Mainly inheritance should be checked any method requiring fragmentactiity should not be used. Also i think you should use startactivity for result – Illegal Argument Jun 15 '14 at 06:37
  • i changed the code to ** Intent intent = new Intent(MainActivity.this, MuPDFActivity.class);** still didnt work – harveyslash Jun 15 '14 at 06:45

0 Answers0