I want to use android downloadManager to download files; But the url is in http basic authentication. And I can get the user name and password in the application. What should I do to download files from my host?
DownloadManager downloadManager = (DownloadManager) appContext.getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
downloadManager.enqueue(request);
This is my code. I want to download file via "url"; But it need http basic authentication. I want to know how to add authentication like this:
httpClient.getState().setCredentials(new AuthScope(HOST, 80), new UsernamePasswordCredentials(user.getEmail(), user.getPassword()));
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…