Adfree really upsets me as an Android Developer. I release apps in the market for FREE and all I ask is the user views ads while they use my app. I like to make a little money, and not take it from my users pockets. I'm assuming if you found this on Google than I am assuming this bothers you too.
I wrote this little bit of code with a buddy of mine to test if the user has Adfree installed on their phone. If it comes back positive (the app is installed), it informs the user that they have adfree installed on their phone, and in order to use the app, they must uninstall it. It then proceeds to close the app, so the user cannot use the app until Adfree is gone.
To begin with, put this in your OnCreate:
adfreetest();
Now, put this code into your app somewhere (its modular, so it will work in any app)
private void adfreetest() {
try{
ApplicationInfo info = getPackageManager()
.getApplicationInfo("com.bigtincan.android.adfree", 0 );
//-- application exists
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("To Use this Application, You Must Uninstall Adfree.")
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
main.this.finish();
}
});
AlertDialog alert = builder.create();
alert.show();
} catch( PackageManager.NameNotFoundException e ){
//-- application doesn't exist
}
}
Make sure to change main in main.this.finish(); to the name of your activity.
If you find a better way to do this, please post!