2015년 6월 28일 일요일

android proxy setting check

안드로이드 wifi proxy 체크

http://stackoverflow.com/questions/10811698/getting-wifi-proxy-settings-in-android

public static String[] getUserProxy(Context context)
{
    Method method = null;
    try
    {
      method = ConnectivityManager.class.getMethod("getProxy");
    }
    catch (NoSuchMethodException e)
    {
      // Normal situation for pre-ICS devices
      return null;
    }
    catch (Exception e)
    {
      return null;
    }

    try
    {
      ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
      Object pp = method.invoke(connectivityManager);
      if (pp == null)
        return null;

      return getUserProxy(pp);
    }
    catch (Exception e)
    {
      return null;
    }
  }


private static String[] getUserProxy(Object pp) throws Exception
{
    String[] userProxy = new String[3];

    String className = "android.net.ProxyProperties";
    Class<?> c = Class.forName(className);
    Method method;

    method = c.getMethod("getHost");
    userProxy[0] = (String) method.invoke(pp);

    method = c.getMethod("getPort");
    userProxy[1] = String.valueOf((Integer) method.invoke(pp));


    method = c.getMethod("getExclusionList");
    userProxy[2] = (String) method.invoke(pp);

    if (userProxy[0] != null)
      return userProxy;
    else
      return null;
}

댓글 없음:

댓글 쓰기

3gb minning

비트코인 골드 -- 마이너 다운로드 :  https://www.bminercontent.com/releases/bminer-v6.0.0-d111154-amd64.zip -- vcruntime140.dll 다운로드  https://www.micr...