2011-02-25 57 views
3

我看到的使用谷歌文档在线阅读PDF文件的方式来读取本地pdf文件...有没有办法使用谷歌文档

Android - Load PDF/PDF Viewer

有没有我们可以用它来查看当地的一种方式存储在SD卡中的文件

+0

它很长时间等待响应..但可以试试这个。 http://androidyoungashram.blogspot.in/2011/02/read-pdf-in-android-without-third-party.html – CoDe 2013-09-14 08:24:47

回答

0

您可以启动一个意图,允许用户选择使用以下代码打开PDF的应用程序,该代码适用于任何文件和mimetype。如果用户没有可打开的应用程序,则可以显示错误或执行其他任何您需要的操作。

请注意,该文件必须是世界可读的,所以如果它位于内部存储器上,或者它必须位于外部存储器中,则必须将其标记为。

private void openFile(File f, String mimeType) 
{ 
    Intent viewIntent = new Intent(); 
    viewIntent.setAction(Intent.ACTION_VIEW); 
    viewIntent.setDataAndType(Uri.fromFile(file), mimeType); 
    // using the packagemanager to query is faster than trying startActivity 
    // and catching the activity not found exception, which causes a stack unwind. 
    List<ResolveInfo> resolved = getPackageManager().queryIntentActivities(viewIntent, 0); 
    if(resolved != null && resolved.size() > 0) 
    { 
     startActivity(viewIntent); 
    } 
    else 
    { 
     // notify the user they can't open it. 
    } 
} 
+0

Sry ..我想要它在我的应用程序中... – xydev 2011-02-25 05:22:32

+0

要做到这一点,你会必须编写自己的PDF解析器,或者使用某种第三方库。这是使用其他应用程序提供功能的“Android方式”:对于用户而言,打开PDF或其他文件的阅读器会感觉像是您的应用程序的一部分。 – 2011-02-25 05:27:13

+0

webview不呈现在iPhone中的pdf ..我可能采用一个网络,一次只显示一个页面。 – xydev 2011-02-25 05:31:17

相关问题