0
我想從pdfviewer中的URL打開pdf在pdfviewer中打開pdf文件
我嘗試下面的代碼。它的開放pdfviewer,但與最近的文件不與我的網址?
如何在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)));
}
}
不工作仍然 – Nick
嘗試更新的代碼 – Ameer
什麼更新?這是更新 – Nick