开发者

Android read handset proxy settings

开发者 https://www.devze.com 2023-01-06 18:30 出处:网络
If user behind proxy he can set proxy settings in开发者_StackOverflow android handset under \'access point option\' is there a way i can read proxy settings from android handset?The android.net.Proxy

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


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.)


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消