2
      final OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .readTimeout(60, TimeUnit.SECONDS)
            .addInterceptor(new Interceptor() {
                @Override
                public okhttp3.Response intercept(Chain chain) throws IOException {
                    Request.Builder ongoing = chain.request().newBuilder();
                    ongoing.addHeader("Cache-Control", "no-cache");
                    ongoing.addHeader("User-Agent", System.getProperty("http.agent"));
                    return chain.proceed(ongoing.build());
                }
            })
            .connectTimeout(100, TimeUnit.SECONDS)
            .build();
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(globalUrl())
                .addConverterFactory(GsonConverterFactory.create())
                .client(okHttpClient)
                .build();

So basically, am doing that in my android code. However, if a device is rooted or am using proxy ( steps below) the url is still being submitted and working.How can I disable under such measures the calls.

1 - Connect to WIFI network (e.g. 'Alex')
2 - Settings->WIFI
3 - Long tap on connected network's name (e.g. on 'Alex')
4 - Modify network config-> Show advanced options
5 - Set proxy settings
krikor Herlopian
  • 731
  • 1
  • 10
  • 23

1 Answers1

2

Manually configure NO_PROXY as your proxy in OkHttpClient.Builder. It’s an option on java.net.Proxy.

Jesse Wilson
  • 39,078
  • 8
  • 121
  • 128
  • I implemented that, final OkHttpClient okHttpClient = new OkHttpClient.Builder() .proxy(Proxy.NO_PROXY) However the url call still works but not using proxy. I like to disable it all together. – krikor Herlopian Sep 28 '16 at 05:55