Android DownLoadManager下载文件Demo

1.权限

View Code
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

 

2.方法

View Code
    public void begainDownload(String downLoadUrl) {
    DownloadManager dm = (DownloadManager)getSystemService( DOWNLOAD_SERVICE);
    DownloadManager.Request   down=new DownloadManager.Request (Uri.parse(downLoadUrl));
    down.setVisibleInDownloadsUi(true);
    down.setDestinationInExternalFilesDir(this, Environment.getExternalStorageDirectory().toString(), "122312.mp3");
    down.setShowRunningNotification(true);
    dm.enqueue(down);
    }

 

 

 

posted @ 2013-04-09 16:18  double0zhou  阅读(511)  评论(0编辑  收藏  举报