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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With