如何阻止广告免费阻止我的应用中的广告?

时间:2011-04-07 17:56:01

标签: android testing block

Adfree真的让我失望了作为Android开发者。我在市场上免费发布应用程序,我要求的是用户在使用我的应用程序时查看广告。我喜欢赚一点钱,而不是从我的用户口袋里取出来。我假设如果你在谷歌上发现这个,我认为这也困扰你 我和我的一个伙伴写了一小段代码来测试用户是否在他们的手机上安装了Adfree。如果它恢复正面(安装了应用程序),它会通知用户他们的手机上已安装了adfree,并且为了使用该应用程序,他们必须将其卸载。然后它继续关闭应用程序,因此在Adfree消失之前用户无法使用该应用程序。
首先,将其放入OnCreate:

adfreetest();

现在,将此代码放入您的应用程序(其模块化,因此它可以在任何应用程序中使用)

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
    }
}

务必将 main.this.finish(); 中的main更改为您活动的名称。
如果您找到更好的方法,请发布!

1 个答案:

答案 0 :(得分:2)

我可以提出的唯一建议是:

祝福,

Phil Lello

相关问题