12

I have an app with a WebView, which downloads videos and plays them in a VideoView.

To manage the downloads I use android's handy DownloadManager API. Unfortunately in some situations I need to use a proxy.

I have successfully set up the proxy for the WebView using reflection as detailed in this stackoverflow question, but I am not sure how I can set the DownloadManager to use a proxy as well..

Is this possible? If not, what are my alternatives?

Thanks

1
  • 1
    @Daniel: You cannot specify a proxy for a DownloadManager.Request. Apr 2, 2016 at 20:42

1 Answer 1

7

I couldn't find a way to do this with the DownloadManager so I ended up implementing my own (simplified) download manager using an AsyncTask.

It's possible then to pass a Proxy object to Url.openConnection as below:

Proxy proxy = new Proxy(Proxy.Type.HTTP, 
                        new InetSocketAddress(proxyHost, proxyPort));
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxy);

Once you've got the proxied connection you can download content as per usual.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.