Open online pdf file through android intent?

前端 未结 12 1568
醉话见心
醉话见心 2020-12-04 21:53

Currently I have a pdf url, and I would like to simply using the intent to open it, however, it does not work if I put the url in intent

12条回答
  •  一个人的身影
    2020-12-04 22:43

    You can view or download the pdf by either of the two ways i.e by opening it in device in-built browser or in the webview by embedding it in your app.

    To open the pdf in browser,

    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(pdf_url));
    startActivity(browserIntent);
    

    Instead to open in webview,

     Webview webView = (WebView) findViewById(R.id.webView1);
     webView.getSettings().setJavaScriptEnabled(true);
     webView.loadUrl(pdf_url);
    

提交回复
热议问题