I need set a DNS in my app.
I can't figure out how to add it:
//Http Client
OkHttpClient.Builder client = new OkHttpClient.Builder();
client.addInterceptor(interceptor);
client.dns("172.10.0.100");
You can set the DNS via the WIFI settings and then just do this:
client.dns(Dns.SYSTEM);
now it should get the info from there.
This is an example of setting an alternative DNS strategy or per host overrides
Dns dns = ...
builder.dns(dns);
See this post dns-android-okhttp and add dependency which I defined below, and it will work :)
compile 'dnsjava:dnsjava:2.1.7'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.