使用自带的pdf阅读器,打开pdf文档。如果没有阅读器,链接到android市场(Google Play Store,360手机助手等)下载。
File file = new File(pdfPath);
Intent intent = new Intent("android.intent.action.VIEW");
intent.addCategory("android.intent.category.DEFAULT");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(Uri.fromFile(file), "application/pdf");
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
Intent marketIntent = new Intent(Intent.ACTION_VIEW);
marketIntent.setData(Uri.parse("market://search?q=PDF"));
startActivity(marketIntent);
}
想要了解更多market://的知识,请点击http://blog.csdn.net/liucaoye/article/details/41449059
想要了解各种类型文件(“.html”,".doc",".mp3"上百种类型)对应的setDataAndType的参数,参考 http://www.2cto.com/kf/201201/117389.html
想要了解Intent的各种跳转(email,短信,map,电话等),参考http://luhuajcdd.iteye.com/blog/1560225