如何从资产中读取pdf和doc文件到android中的webview?

时间:2012-07-31 07:38:22

标签: android

File file=new File("file:///android_asset"+filename);

if (file.exists()) {
        Uri targetUri = Uri.fromFile(file);
        Intent intent1 = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(targetUri, "application/pdf");
            try {
                startActivity(intent1);
            } 
            catch (ActivityNotFoundException e) {
                Toast.makeText(FileWebView.this, 
                     "No Application Available to View PDF", 
                      Toast.LENGTH_SHORT).show();
            }

0 个答案:

没有答案