如果没有为阅读器显示下载链接,我想检查android
是否有默认的Excel阅读器。这可能吗?
答案 0 :(得分:2)
您可以使用PackageManager.resolveActivity()
确定是否安装了可以查看该文件的内容。这是一个例子:
PackageManager pm = getPackageManager();
File file = new File("filename"); // This is the file you want to show
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.fromFile(file));
// Determine if Android can resolve this implicit Intent
ResolveInfo info = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (info != null) {
// There is something installed that can VIEW this file)
} else {
// Offer to download a viewer here
}