Android 使用PDFViewer.jar从资产文件夹读取pdf

Android 使用PDFViewer.jar从资产文件夹读取pdf,android,pdf,assets,Android,Pdf,Assets,我想使用PDFViewer.jar读取存储在资产文件夹中的pdf文件 我尝试了这种方式,但我得到了错误消息,它得到不幸的停止 有人能帮我怎么实施吗 public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout

我想使用
PDFViewer.jar
读取存储在资产文件夹中的pdf文件

我尝试了这种方式,但我得到了错误消息,它得到不幸的停止

有人能帮我怎么实施吗

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    CopyReadAssets();

}

private void CopyReadAssets() {
    AssetManager assetManager = getAssets();

    InputStream in = null;
    OutputStream out = null;
    File file = new File(getFilesDir(), "ABC.pdf");
    try {
        in = assetManager.open("ABC.pdf");
        out = openFileOutput(file.getName(), Context.MODE_WORLD_READABLE);

        copyFile(in, out);
        in.close();
        in = null;
        out.flush();
        out.close();
        out = null;
    } catch (Exception e) {
        Log.e("tag", e.getMessage());
    }

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(
            Uri.parse("file://" + getFilesDir() + "/ABC.pdf"),
            "application/pdf");

    startActivity(intent);
}

private void copyFile(InputStream in, OutputStream out) throws IOException {
    byte[] buffer = new byte[1024];
    int read;
    while ((read = in.read(buffer)) != -1) {
        out.write(buffer, 0, read);
    }
}


}
logcat详细信息:

 02-05 11:09:05.896: E/AndroidRuntime(6516): FATAL EXCEPTION: main
 02-05 11:09:05.896: E/AndroidRuntime(6516): java.lang.RuntimeException: Unable to start activity  
   ComponentInfo{com.syntel.pdfreader/com.syntel.pdfreader.MainActivity}: 
   android.content.ActivityNotFoundException:   No Activity found to handle Intent {
    act=android.intent.action.VIEW dat=file:///data/data/com.syntel.pdfreader/files/ABC.pdf typ=application/pdf    }
  02-05 11:09:05.896: E/AndroidRuntime(6516):   at    

  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
  02-05 11:09:05.896: E/AndroidRuntime(6516):   at  
 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
  02-05 11:09:05.896: E/AndroidRuntime(6516):   at 
  android.app.ActivityThread.access$600(ActivityThread.java:141)
 02-05 11:09:05.896: E/AndroidRuntime(6516):    at 
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
  02-05 11:09:05.896: E/AndroidRuntime(6516):   at android.os.Handler.dispatchMessage(Handler.java:99)
 02-05 11:09:05.896: E/AndroidRuntime(6516):    at android.os.Looper.loop(Looper.java:137)
02-05 11:09:05.896: E/AndroidRuntime(6516):     at 
  android.app.ActivityThread.main(ActivityThread.java:5041)
02-05 11:09:05.896: E/AndroidRuntime(6516):     at java.lang.reflect.Method.invokeNative(Native Method)
02-05 11:09:05.896: E/AndroidRuntime(6516):     at java.lang.reflect.Method.invoke(Method.java:511)
02-05 11:09:05.896: E/AndroidRuntime(6516):     at 
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
 02-05 11:09:05.896: E/AndroidRuntime(6516):    at 
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
 02-05 11:09:05.896: E/AndroidRuntime(6516):    at dalvik.system.NativeStart.main(Native Method)
 02-05 11:09:05.896: E/AndroidRuntime(6516): Caused by: android.content.ActivityNotFoundException: No Activit
y found to handle Intent { act=android.intent.action.VIEW 
  dat=file:///data/data/com.syntel.pdfreader/files/ABC.pdf typ=application/pdf }
02-05 11:09:05.896: E/AndroidRuntime(6516):     at  
 android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1622)
02-05 11:09:05.896: E/AndroidRuntime(6516):     at 
android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)

我已经用这个创建了我的现场演示


你们可以下载我的

@PratikButani路径意味着它的jar文件,所以我把它保存在了库中folder@PratikButani从www.ziddu.com/download/19248664/PdfViewer.jar.htmlWill您能发布您的logcat错误吗?@PratikButaniI我有相同的代码,但我不知道为什么找不到它exception@PratikButaniok你能给出你的答案吗电子邮件id