Code example for Constructor

Methods: newInstance, setAccessible

0
    if (webViewCoreClass != null && proxyPropertiesClass != null) {
      Method m =
          webViewCoreClass.getDeclaredMethod("sendStaticMessage", Integer.TYPE, Object.class);
      Constructor c = proxyPropertiesClass.getConstructor(String.class, Integer.TYPE, String.class);
      m.setAccessible(true);
      c.setAccessible(true);
      Object properties = c.newInstance(host, port, null);
      m.invoke(null, PROXY_CHANGED, properties);
      return true; 
    } 
    return false; 
  } 
 
  private static void setSystemProperties(String host, int port) {
 
    System.setProperty("http.proxyHost", host);
    System.setProperty("http.proxyPort", port + "");
 
    System.setProperty("https.proxyHost", host);
    System.setProperty("https.proxyPort", port + "");
  }