如何在android emulator中使用url在webview中直接读取pdf文件
我想在android模拟器中从url读取pdf文件 我已经做了以下工作,但它不起作用如何在android emulator中使用url在webview中直接读取pdf文件,android,android-emulator,Android,Android Emulator,我想在android模拟器中从url读取pdf文件 我已经做了以下工作,但它不起作用 WebView web1 =(WebView)findViewById(R.id.webview); web1.getSettings().setJavaScriptEnabled(true); web1.loadUrl("http://docs.google.com/viewer?url=http%3A%2F%2Fwww.cranialtech.com%2Fimages%2Fstori
WebView web1 =(WebView)findViewById(R.id.webview);
web1.getSettings().setJavaScriptEnabled(true);
web1.loadUrl("http://docs.google.com/viewer?url=http%3A%2F%2Fwww.cranialtech.com%2Fimages%2Fstories%2FFiles%2Fpositioningprotocol.pdf");
及
但它仍然不起作用
请帮帮我
提前谢谢
请尝试以下代码:
Uri path = Uri.parse("http://docs.google.com/viewer?url=http%3A%2F%2Fwww.cranialtech.com%2Fimages%2Fstories%2FFiles%2Fpositioningprotocol.pdf");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf"); //Set data type
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try
{
startActivity(intent);
}
catch (ActivityNotFoundException e)
{
Toast.makeText(this," pdf not found",
Toast.LENGTH_SHORT).show();
}
WebView web1 =(WebView)findViewById(R.id.webview);
web1.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("http://docs.google.com/gview?embedded=true&url=http://docs.google.com/viewer?url=http%3A%2F%2Fwww.cranialtech.com%2Fimages%2Fstories%2FFiles%2Fpositioningprotocol.pdf");