如何为Android应用中的所有连接设置代理?

问题描述 投票:1回答:1

我想使用this library在我的Android应用中播放一些youtube视频。但在我们国家/地区,YouTube被阻止。我想使用代理或其他任何方式,仅用于我的应用程序来解决此问题。

我尝试了此代码,但除admob广告(可能由于使用了Google Play服务)之外,所有连接均失败:

    System.setProperty("http.proxyHost", proxyHost);
    System.setProperty("http.proxyPort", proxyPort);
    System.setProperty("https.proxyHost", proxyHost);
    System.setProperty("https.proxyPort", proxyPort);

我也尝试this library,但所有连接都在我的应用程序中丢失。有没有一种方法可以仅对我的应用中的所有连接使用代理,而不是对所有设备使用代理?

android http-proxy androidhttpclient
1个回答
0
投票

如果将代理的使用限制为自己的应用程序,则可以使用ProxyProxySelector API。

© www.soinside.com 2019 - 2024. All rights reserved.