我现在执行的一个程序,尽管用户可以读取pdf文件,但是如果pdf 阅读器不在程序中的话,应用程序就自动从网站上安装它。
这是阅读pdf文件的代码:
File file = new File("/sdcard/sample.pdf");
PackageManager packageManager = getPackageManager();
Intent testIntent = new Intent(Intent.ACTION_VIEW);
testIntent.setType("application/pdf");
List list = packageManager.queryIntentActivities(testIntent, PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() > 0 && file.isFile()) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(file);
intent.setDataAndType(uri, "application/pdf");
startActivity(intent);
}
我的疑惑是:
1.如何检查电话中是否安装adobe reader ?
2. 如何以程序的方式在电话中安装 adobe reader ?