Android读取手机代理设置

发布于 2024-09-08 19:15:22 字数 76 浏览 1 评论 0原文

如果用户在代理后面,他可以在“接入点选项”下的 Android 手机中设置代理设置,有没有办法我可以从 Android 手机读取代理设置?

If user behind proxy he can set proxy settings in android handset under 'access point option' is there a way i can read proxy settings from android handset?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

×纯※雪 2024-09-15 19:15:23

android.net.Proxy 类只会为您提供主机和端口 - 我的代理也需要用户名和密码。

我能够挖掘 Android 源代码并找到其他代理值的存储位置。这在 Android 调试器中有效 - 我还没有在实际设备上尝试过。

String proxy;
int port = -1;
String user;
String password;
Uri uri = Uri.parse("content://telephony/carriers/current");
Cursor cursor = managedQuery(uri, 
            new String[]{"proxy", "port", "user", "password"}, 
            null, null, null);
if (cursor.moveToNext()) {
    proxy = cursor.getString(0);
    port = cursor.getInt(1);
    user = cursor.getString(2);
    password = cursor.getString(3);
}

com.android.providers.telephony.TelephonyProvider 包含 URI 和列名称。)

The android.net.Proxy class will only give you the host and port - my proxy required user and password also.

I was able to dig through the Android source and found where the other proxy values are stored. This works in the Android debugger - I haven't tried this on an actual device.

String proxy;
int port = -1;
String user;
String password;
Uri uri = Uri.parse("content://telephony/carriers/current");
Cursor cursor = managedQuery(uri, 
            new String[]{"proxy", "port", "user", "password"}, 
            null, null, null);
if (cursor.moveToNext()) {
    proxy = cursor.getString(0);
    port = cursor.getInt(1);
    user = cursor.getString(2);
    password = cursor.getString(3);
}

(Android source of com.android.providers.telephony.TelephonyProvider that contained the URI and column names.)

坏尐絯 2024-09-15 19:15:23

您可以使用 android.net.Proxy 类来获取有关 Proxy 的信息主机和端口。

You can use android.net.Proxy class to get info about Proxy Host and Port.

椵侞 2024-09-15 19:15:23

我正在开发 Android 代理库 尝试抽象每个 Android 版本对代理设置的访问权限。您可以轻松获取用户当前选择的代理设置。

I'm developing the Android Proxy Library that try to abstract the access to proxy settings for every Android version. You can easily get the proxy settings currently selected by the user.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文