开发者

Is there a way to disable the hosts file at an application level in Android?

I'm trying to get around using the hosts file DNS overrid开发者_StackOverflow社区es in my application. Is there an application property or TCP setting that would allow me to do this? Alternately is there a DNS hook at an application level?

I'm basically trying to get around the ad blocking hosts files custom ROM folks put in place, but to do it at an application level.

Essentially, if people don't like the ads, don't use my app, but I don't want to be a prick and have the app not run.


Is there an application property or TCP setting that would allow me to do this?

No. For your own IP addresses (e.g., HTTP request), you are welcome to find some Java DNS resolution library and use it instead of the system one, but there is no way to intercept other requests from third-party code in your app.

Alternately is there a DNS hook at an application level?

No. See above.

Essentially, if people don't like the ads, don't use my app, but I don't want to be a prick and have the app not run.

Then you should fix (or work with your ad network to fix) the reasons why your app does not run when users have an "ad blocking hosts files custom ROM" installed. An ad banner should not crash because it cannot resolve DNS, as there are reasons that might fail that have nothing to do with "ad blocking hosts files custom ROM" (e.g., DNS server having a conniption).

Since you didn't explain what "not run" means in this context, it is difficult to provide you with more concrete advice.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜