Reputation: 300
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.
Upvotes: 0
Views: 1568
Reputation: 572
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?
Upvotes: 0
Reputation: 20426
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) { }
});
Upvotes: 1