0

As you know, many people are using custom roms. almost all custom roms ve changed hosts file which is blocking access(sends requests to 127.0.0.1 for ads) to admob.

is there any way to overcome about it ? Perhaps not possible to change hosts file programmatically but maybe we can define the ip for admob in our apps,cant we? as such issues what are you doing for prevent an adblocker?

i wouldnt prefer to block my app to using by users if the app detects an adblocker.

LikePod
  • 300
  • 1
  • 4
  • 17
  • 1
    possible duplicate of [How to prevent ad blocker from blocking ads on an app](http://stackoverflow.com/questions/3452907/how-to-prevent-ad-blocker-from-blocking-ads-on-an-app) – Kai Apr 01 '14 at 12:51
  • I think you are worrying needlessly. Less that 1% of people are using custom roms or Ad Blockers (stats that I compiled myself after also being concerned about this). Do you really want to code for 1% of all eventualities or do you want to invest some time in more functionality? – William Aug 28 '13 at 01:18

2 Answers2

1

You can use AdListener to detect whether your AdView receives ads or not. It it has not been receiving ads for a long period of time (e.g. couple of days in a row) but the app was used, you can start blocking it.

AdView adView = new AdView(activity, AdSize.BANNER, "xxxxxxxxxx");
adView.setAdListener(new AdListener() {
    @Override public void onReceiveAd(Ad arg0) { }
    @Override public void onPresentScreen(Ad arg0) {  }
    @Override public void onLeaveApplication(Ad arg0) { }
    @Override public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
        // implement this method
    }
    @Override public void onDismissScreen(Ad arg0) { }
});
sergej shafarenka
  • 20,071
  • 7
  • 67
  • 86
0

If you are using standard system calls to resolve a host to IP, there is not much you can do to prevent a user from controlling how their DNS is configured to resolve. I haven't done this on Android, but you could roll out your own DNS resolution function goes out by itself to a DNS server such as Google's 8.8.8.8 and resolves an IP for you.

The other alternative, as you mentioned, is to simply use IP addresses, possibly one you own, and then redirect to wherever you want.

Or best yet, just let users control what they do with their DNS? Has this really been such a big problem?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
elec3647
  • 513
  • 5
  • 8