Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any sample code for viewing a pdf file? #24

Open
GoogleCodeExporter opened this issue Jun 15, 2015 · 0 comments
Open

Any sample code for viewing a pdf file? #24

GoogleCodeExporter opened this issue Jun 15, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

Is there any sample code to view a pdf file? I got an empty screen when I 
compile the latest source code. So I add a new main activity. And add the 
following code when I click a button to open a pdf in my sdcard:


                // open pdfviewactivity
                File dir = Environment.getExternalStorageDirectory();
                File yourFile = new File(dir, "book.pdf");

                Intent intent =  new Intent(Intent.ACTION_VIEW, Uri.fromFile(yourFile));
                startActivity(intent);              

Unfortunately it crashes. The error message is:


05-16 13:13:36.652: E/AndroidRuntime(12364): FATAL EXCEPTION: main
05-16 13:13:36.652: E/AndroidRuntime(12364): 
android.content.ActivityNotFoundException: No Activity found to handle Intent { 
act=android.intent.action.VIEW dat=file:///mnt/sdcard/book.pdf }

My androidmanifest.xml is:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.googlecode.apdfviewer" >

    <application android:label="@string/app_name" >
        <activity
            android:name="com.googlecode.apdfviewer.PDFViewerActivity"
            android:label="PDFViewer"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="file" />
                <data android:scheme="content" />
                <data android:mimeType="application/pdf" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.googlecode.apdfviewer.MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Any clue? Thanks.

Original issue reported on code.google.com by [email protected] on 16 May 2013 at 1:22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant