如何阻止 Adfree 阻止我的应用程序中的广告?

发布于 2024-10-31 01:47:28 字数 1425 浏览 4 评论 0 原文

 作为一名 Android 开发者,无广告确实让我感到不安。我在市场上免费发布应用程序,我所要求的只是用户在使用我的应用程序时查看广告。我喜欢赚一点钱,而不是从用户的口袋里拿钱。我假设如果您在 Google 上找到了此内容,那么我假设这也会困扰您。
我和我的一个朋友写了这段代码来测试用户的手机上是否安装了 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 更改为您的活动名称。
如果您找到更好的方法来做到这一点,请发布!

  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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怂人 2024-11-07 01:47:28

我能提出的唯一建议是:

  • 也提供付费版本,并向用户指出这一点。
  • 可能会在您的应用程序运行时提供禁用无广告功能。我还没有尝试过这个,但是 PackageManager.setApplicationEnabled 可能会有所帮助

祝您好运,

Phil Lello

The only suggestions I can make are:

  • Offer a paid version too, and point the user at that.
  • Possibly offer to disable adfree while your app is running. I haven't tried this, but PackageManager.setApplicationEnabled might help

Best wishes,

Phil Lello

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文