2015-06-21 48 views
0

我用下載管理器下載PDF文件文件採取的查詢字符串(如。www.example.com/files?id=123)

和它的下載以及我從下載網址如下:http://www.example.com/file.pdf

,但它不是下載我從一個下載這樣的:
http://www.example.com/files?id=123 (下載失敗)

String url = "url to download"; 
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); 

request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "name-of-the-file.pdf"); 

// get download service and enqueue file 
DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); 
manager.enqueue(request); 

問題是如何從網址下載這樣http://www.example.com/files?id=123

在此先感謝

+1

我不知道'http:// www.example.com/files&id = 123'是一個有效的URL。請提供一個有'&'但沒有'?'的工作網址。 – CommonsWare

+0

如果您對&符號進行urlencode編碼,會發生什麼情況? (%26)編輯:CommonsWare也有一點。它是文件的名稱,還是僅僅是一個參數?如果它是一個參數,那麼問號也是必需的,否則它是無效的。 – skandigraun

+0

你是對的,我必須編寫http:www.example.com/files?id = 1 –

回答