AdFreeDetector is open sourced
AdFree Android is now available on the Android market. It allows anyone with root/super user access on their phone to download a replacement hosts file for their device which redirects ad URLs to itself. This has the effect of saving bandwidth and speeding up browsing.
I agree ads are annoying, especially on a tiny phone screen. But Google’s Android Market does not allow developers from many countries to publish paid apps. The only way for those developers to get some income from the Market is to publish apps with ad banners. AdFree is a brutal solution to alter hosts file and leaving a gaping blank block within the app (since the ad banners cannot complete the retrieval).
It’s all about choices. You can install AdFree to block ads, we can include AdFreeDetector to find it, and do something about it.
AdFreeDetector detects whether the Android phone has AdFree package installed, as well as finding out if your ad network IP has been altered (and thus no ads will be shown to the user).
It’s a simple JAR lib that you can include in your Android apps.
It’s open sourced under Apache License V2 here:
http://code.google.com/p/adfree-detector/
Please feel free to submit a patch and make it better
Sample usage:
Make sure your AndroidManifest?.xml has these lines:
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
To check if the Android device has AdFree package installed:
boolean flag = Detector.isAdFreeInstalled(context);
To check if hosts file has been altered, the default checking is on “googleads.g.doubleclick.net”
boolean isAltered = Detector.isHostAltered(context, null);
To check specific hostname, such as AdMob?: analytics.admob.com
isAltered = Detector.isHostAltered(context, "analytics.admob.com");
Have fun![]()