开发者

how to: download and open a pdf file programmatically via http connection

开发者 https://www.devze.com 2023-03-17 23:13 出处:网络
how to: download (via an http connection) and open or save a pdf file programmatically. Say I have a button on my screen and the url to the pdf, when the button i开发者_运维百科s clicked I want to do

how to: download (via an http connection) and open or save a pdf file programmatically.

Say I have a button on my screen and the url to the pdf, when the button i开发者_运维百科s clicked I want to download the pdf from the url and have the user presented with the choice to open or save the file. There must be a standard way to do something so commonplace, should I open the browser to the url or can I do this from my app?


Like this:

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("*url for your pdf*"));
startActivity(browserIntent);

This will cause the pdf to be downloaded in the notification bar, as if you had initiated the download through the browser.

Check this question if you have problems: How can I open a URL in Android's web browser from my application?

0

精彩评论

暂无评论...
验证码 换一张
取 消