13

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

Community
  • 1
  • 1
Ed_
  • 18,798
  • 8
  • 45
  • 71

1 Answers1

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.

Ed_
  • 18,798
  • 8
  • 45
  • 71