2011-07-04 24 views
0

アンドロイドエミュレータでurlからpdfファイルを読みたいです。アンドロイドエミュレータでURLを使用してwebviewで直接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%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(); 
    } 

が動作していない。しかし、それはまだ動作していません。

助けてください

ありがとうございます。

答えて

1

は、このコードを試してみてください::

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"); 
関連する問題