2011-06-30 17 views
1

リモートURLからアプリでPDFを開きたいとします。私を助けてください。私のアプリからリモートURLからアンドロイドのpdfを開くにはどうすればいいですか

Uri path = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.wsa); 
     final String googleDocsUrl = "http://docs.google.com/viewer?url="; 

Intent intent = new Intent(Intent.ACTION_VIEW); 
intent.setDataAndType(Uri.parse(googleDocsUrl +path), "text/html"); 

ありがとうございます。

答えて

1
WebView webView=(WebView)this.findViewById(R.id.WebView01); 
     Intent intent = new Intent(Intent.ACTION_VIEW); 
     webView.getSettings().setJavaScriptEnabled(true); 
     webView.getSettings().setAllowFileAccess(true); 
     webView.getSettings().setPluginsEnabled(true); 
     webView.loadUrl("https://docs.google.com/viewer?url=http%3A%2F%2Fwww.eli.sdsu.edu%2Fcourses%2Ffall09%2Fcs696%2Fnotes%2FAndroid13Web.pdf"); 


     try { 
      startActivity(intent); 
     } 
     catch (ActivityNotFoundException e) { 
      Toast.makeText(ReaderActivity.this, 
       "No Application Available to View PDF", 
       Toast.LENGTH_SHORT).show(); 
     } 

自分のコードで正しく動作しているように見えます。 私はそれがあなたに役立つことを願っています。

-1

次のコード

Intent intent = new Intent(Intent.ACTION_VIEW); 
intent.setDataAndType(Uri.parse("http://14.140.41.194/monali/i.pdf"), "application/pdf"); 
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
で試してみてくださいアプリケーション/ PDFとして

をMIMEタイプを提供する必要があります

関連する問題