我想在 pdfviewer 中从 URL 打开 pdf
我尝试下面的代码。它打开 pdfviewer 但最近的文档没有我的 URL 吗?
如何直接在pdfviewer中打开文件?
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://inventwithpython.com/hackingciphers.pdf"));
intent.setType("application/pdf");
PackageManager pm = getPackageManager();
List<ResolveInfo> activities = pm.queryIntentActivities(intent, 0);
if (activities.size() > 0) {
startActivity(intent);
} else {
// Do something else here. Maybe pop up a Dialog or Toast
Toast.makeText(getApplicationContext(),"No pdf found" , Toast.LENGTH_LONG).show();
final String appName = "com.adobe.reader";
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+appName)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id="+appName)));
}
}