title: Geolocation webview
body: <p>How can I set a static  location in webview?
  It should not be changed even if the application is used from a different  location
  I tried to change the proxy, but it didn't work. Are there other ways?
  I'm trying to get users to use a location doesn't change
  I'm trying to get users to use a location doesn't change</p>
  <pre><code> public static class ProxySettings {
  
          private static final String TAG = &quot;GAEProxy.ProxySettings&quot;;
  
          static final int PROXY_CHANGED = 193;
  
          private static Object getDeclaredField(Object obj, String name) throws SecurityException,
                  NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
              Field f = obj.getClass().getDeclaredField(name);
              f.setAccessible(true);
              Object out = f.get(obj);
              // System.out.println(obj.getClass().getName() + &quot;.&quot; + name + &quot; = &quot;+
              // out);
              return out;
          }
  
          public static Object getRequestQueue(Context ctx) throws Exception {
              Object ret = null;
              Class networkClass = Class.forName(&quot;android.webkit.Network&quot;);
              if (networkClass != null) {
                  Object networkObj = invokeMethod(networkClass, &quot;getInstance&quot;, new Object[] { ctx },
                          Context.class);
                  if (networkObj != null) {ء
                      ret = getDeclaredField(networkObj, &quot;mRequestQueue&quot;);
                  }
              }
              return ret;
          }
  
          private static Object invokeMethod(Object object, String methodName, Object[] params,
                                             Class... types) throws Exception {
              Object out = null;
              Class c = object instanceof Class ? (Class) object : object.getClass();
              if (types != null) {
                  Method method = c.getMethod(methodName, types);
                  out = method.invoke(object, params);
              } else {
                  Method method = c.getMethod(methodName);
                  out = method.invoke(object);
              }
              // System.out.println(object.getClass().getName() + &quot;.&quot; + methodName +
              // &quot;() = &quot;+ out);
              return out;
          }
  
          public static void resetProxy(Context ctx) throws Exception {
              Object requestQueueObject = getRequestQueue(ctx);
              if (requestQueueObject != null) {
                  setDeclaredField(requestQueueObject, &quot;mProxyHost&quot;, null);
              }
          }
  
          private static void setDeclaredField(Object obj, String name, Object value)
                  throws SecurityException, NoSuchFieldException, IllegalArgumentException,
                  IllegalAccessException {
              Field f = obj.getClass().getDeclaredField(name);
              f.setAccessible(true);
              f.set(obj, value);
          }
  
          /**
           * Override WebKit Proxy settings
           *
           * @param ctx
           *            Android ApplicationContext
           * @param host
           * @param port
           * @return true if Proxy was successfully set
           */
          public static boolean setProxy(Context ctx, String host, int port) {
              boolean ret = false;
              setSystemProperties(host, port);
  
              try {
                  if (Build.VERSION.SDK_INT &lt; 27) {
  
                      Object requestQueueObject = getRequestQueue(ctx);
                      if (requestQueueObject != null) {
                          // Create Proxy config object and set it into request Q
                          HttpHost httpHost = new HttpHost(host, port, &quot;http;//&quot;);
  
                          setDeclaredField(requestQueueObject, &quot;mProxyHost&quot;, httpHost);
                          ret = true;
                      }
  
                  } else {
                      ret = setICSProxy(host, port);
                  }
              } catch (Exception e) {
                  Log.e(TAG, &quot;error setting up webkit proxying&quot;, e);
              }
              return ret;
          }
  
          private static boolean setICSProxy(String host, int port) throws ClassNotFoundException,
                  NoSuchMethodException, IllegalArgumentException, InstantiationException,
                  IllegalAccessException, InvocationTargetException {
              Class webViewCoreClass = Class.forName(&quot;android.webkit.WebViewCore&quot;);
              @SuppressLint(&quot;PrivateApi&quot;) Class proxyPropertiesClass = Class.forName(&quot;android.net.ProxyProperties&quot;);
              if (webViewCoreClass != null &amp;&amp; proxyPropertiesClass != null) {
                  Method m = webViewCoreClass.getDeclaredMethod(&quot;sendStaticMessage&quot;, 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(&quot;fe80::eead:e0ff:fe23:eaa3&quot;, host);
              System.setProperty(&quot;fe80::eead:e0ff:fe23:eaa3&quot;, port + &quot;8080&quot;);
              System.setProperty(&quot;33.5102&quot;,&quot;36.29128&quot;);
              System.setProperty(&quot;fe80::84f6:7b62:322a:b253&quot;, host);
              System.setProperty(&quot;fe80::84f6:7b62:322a:b253&quot;, port + &quot;8080&quot;);
  </code></pre>