且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android:如何在Android中创建直接下载链接

更新时间:2021-11-04 08:29:49

那很容易
http://developer.android.com/reference/android/app/DownloadManager.html

示例: http://androidtrainningcenter.blogspot.co.at/2013/05/android-download-manager-example.html

然后在单击文本视图(使用Handler或监听器捕获)后启动此方法

And start this method after clicking the textview (Catch with Handler or listener)

/**
 * Start Download
 */
public void startDownload() {
    DownloadManager mManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
    Request mRqRequest = new Request(
            Uri.parse("http://androidtrainningcenter.blogspot.in/2012/11/android-webview-loading-custom-html-and.html"));
    mRqRequest.setDescription("This is Test File");
//  mRqRequest.setDestinationUri(Uri.parse("give your local path"));
    long idDownLoad=mManager.enqueue(mRqRequest);
}

但是请确保您是最小的。在API 9上

But be sure you are min. on API 9