相关疑难解决方法(0)

使用Android下载文件,并在ProgressDialog中显示进度

我正在尝试编写一个更新的简单应用程序.为此,我需要一个简单的功能,可以下载一个文件,并显示当前进度ProgressDialog.我知道怎么做ProgressDialog,但我不知道如何显示当前进度以及如何首先下载文件.

java android download android-asynctask

1017
推荐指数
11
解决办法
52万
查看次数

Android下载二进制文件问题

我在从我的应用程序中下载二进制文件(视频)时遇到问题.在Quicktime中,如果我直接下载它可以正常工作但通过我的应用程序不知何故它搞砸了(即使它们在文本编辑器中看起来完全相同).这是一个例子:

    URL u = new URL("http://www.path.to/a.mp4?video");
    HttpURLConnection c = (HttpURLConnection) u.openConnection();
    c.setRequestMethod("GET");
    c.setDoOutput(true);
    c.connect();
    FileOutputStream f = new FileOutputStream(new File(root,"Video.mp4"));


    InputStream in = c.getInputStream();

    byte[] buffer = new byte[1024];
    int len1 = 0;
    while ( (len1 = in.read(buffer)) > 0 ) {
         f.write(buffer);
    }
    f.close();
Run Code Online (Sandbox Code Playgroud)

java android download httpurlconnection fileoutputstream

71
推荐指数
4
解决办法
8万
查看次数

如何在Android下载pdf文件?

我想从网址下载pdf文件.为了查看pdf文件,我使用了以下代码.

File file = new File("/sdcard/example.pdf");

if (file.exists()) {
    Uri path = Uri.fromFile(file);
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(path, "application/pdf");
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    try {
        startActivity(intent);
    } 
    catch (ActivityNotFoundException e) {
        Toast.makeText(OpenPdf.this, "No Application Available to View PDF",
            Toast.LENGTH_SHORT).show();
    }
}
Run Code Online (Sandbox Code Playgroud)

它正在工作,但我如何从URL(例如http://.../example.pdf)获取pdf文件.我想从这个网址下载 pdf文件.请帮我.提前致谢.

android download

19
推荐指数
3
解决办法
7万
查看次数