如何防止广告拦截器拦截应用程序上的广告

发布于 2024-09-14 03:19:07 字数 126 浏览 13 评论 0原文

我的一位用户泄露了秘密,并告诉我他们正在使用我的一款免费应用程序,该应用程序通过广告获利,但他们使用广告拦截器来拦截广告。他们用嘲笑的语气告诉我这件事,好像我对此无能为力。

我可以做点什么吗?有没有办法检测广告是否被屏蔽?

One of my users let the cat out of the bag and told me they were using one of my free apps, which is monetized by ads, but they were blocking the ads with an ad blocker. They told me this mockingly, as if I can't do anything about it.

Can I do something about it? Is there a way to detect that ads are being blocked?

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

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

发布评论

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

评论(15

生生漫 2024-09-21 03:19:07

我知道广告拦截的一种工作方式(实际上在任何计算机上),他们编辑主机文件以指向所有已知广告服务器的本地主机。对于 Android,它位于“etc/hosts”文件中。

例如,我使用 admob 广告,并且从自定义 rom 中获取的主机文件列出了以下 admob 条目:

127.0.0.1 analytics.admob.com
127.0.0.1 mmv.admob.com
127.0.0.1 mm.admob.com
127.0.0.1 admob.com
127.0.0.1 a.admob.com
127.0.0.1 jp.admob.com
127.0.0.1 c.admob.com
127.0.0.1 p.admob.com
127.0.0.1 mm1.vip.sc1.admob.com
127.0.0.1 media.admob.com
127.0.0.1 e.admob.com

现在,每当进程尝试解析上述地址时,它们都会被路由到它们左侧列出的地址 (localhost)这个案例。

我在我的应用程序中所做的就是检查此主机文件并查找任何 admob 条目,如果发现任何条目,我会通知用户我已检测到广告拦截,并告诉他们从那里删除 admob 条目并不允许他们使用该应用程序。

毕竟,如果他们看不到广告,这对我有什么好处呢?让他们免费使用该应用程序毫无意义。

以下是我如何实现这一目标的代码片段:

        BufferedReader in = null;

    try 
    {
        in = new BufferedReader(new InputStreamReader(
                new FileInputStream("/etc/hosts")));
        String line;

        while ((line = in.readLine()) != null)
        {
            if (line.contains("admob"))
            {
                result = false;
                break;
            }
        }
    } 

我发誓所有支持广告的应用程序都应该检查此文件。您不需要成为 root 才能访问它,但写入它可能是一个不同的故事。

另外,不确定是否有任何其他文件在基于 Linux 的操作系统上具有相同的作用,但无论如何我们总是可以检查所有这些文件。

欢迎任何有关改进这一点的建议。

此外,名为“Ad Free android”的应用程序需要 root 访问权限,这意味着它很可能会更改主机文件以实现其目标。

I am aware of one way that ad blocking works (on any computer really), they edit the hosts file to point to localhost for all known ad servers. For android this is located in the "etc/hosts" file.

For example, I use admob ads and a host file that I have taken from custom rom lists the folowing admob entries:

127.0.0.1 analytics.admob.com
127.0.0.1 mmv.admob.com
127.0.0.1 mm.admob.com
127.0.0.1 admob.com
127.0.0.1 a.admob.com
127.0.0.1 jp.admob.com
127.0.0.1 c.admob.com
127.0.0.1 p.admob.com
127.0.0.1 mm1.vip.sc1.admob.com
127.0.0.1 media.admob.com
127.0.0.1 e.admob.com

Now anytime a process tries to resolve the above addresses they are routed to the address listed to the left of them (localhost) in this case.

What I do in my apps is check this host file and look for any admob entries, if I find any I notify the user that I've detected ad blocking and tell them to remove admob entries from there and do't allow them use of the app.

After all what good does it do me if they're not seeing ads? No point in letting them use the app for free.

Here is a code snippet of how I achieve that:

        BufferedReader in = null;

    try 
    {
        in = new BufferedReader(new InputStreamReader(
                new FileInputStream("/etc/hosts")));
        String line;

        while ((line = in.readLine()) != null)
        {
            if (line.contains("admob"))
            {
                result = false;
                break;
            }
        }
    } 

I vow that all ad supported apps should check this file. You do not need to be root in order to access it, but writing to it might be a different story.

Also, not sure if there is any other files that act the same on a linux based OS, but at any rate we can always check all of those files.

Any suggestions on improving this are welcome.

Also the app called "Ad Free android" needs root access, meaning that it most likely changes the hosts file in order to achieve its goal.

作妖 2024-09-21 03:19:07

我针对这个问题的代码是: -

try {
    if (InetAddress.getByName("a.admob.com").getHostAddress().equals("127.0.0.1") ||
        InetAddress.getByName("mm.admob.com").getHostAddress().equals("127.0.0.1") ||
        InetAddress.getByName("p.admob.com").getHostAddress().equals("127.0.0.1") ||
        InetAddress.getByName("r.admob.com").getHostAddress().equals("127.0.0.1")) {
        //Naughty Boy - Punishing code goes here.
        // In my case its a dialog which goes to the pay-for version 
        // of my application in the market once the dialog is closed.
    }
} catch (UnknownHostException e) { } //no internet

希望有帮助。

My code for this issue is thusly: -

try {
    if (InetAddress.getByName("a.admob.com").getHostAddress().equals("127.0.0.1") ||
        InetAddress.getByName("mm.admob.com").getHostAddress().equals("127.0.0.1") ||
        InetAddress.getByName("p.admob.com").getHostAddress().equals("127.0.0.1") ||
        InetAddress.getByName("r.admob.com").getHostAddress().equals("127.0.0.1")) {
        //Naughty Boy - Punishing code goes here.
        // In my case its a dialog which goes to the pay-for version 
        // of my application in the market once the dialog is closed.
    }
} catch (UnknownHostException e) { } //no internet

Hope that helps.

烟酒忠诚 2024-09-21 03:19:07

作为开发人员,我们需要完成与用户产生共鸣的艰巨工作,并在惩罚少数试图利用用户利益的人和许多遵守规则的人之间找到一个中间立场。移动广告是允许某人免费使用功能性软件的合理方式。使用广告拦截技术的用户可能会被视为收入损失,但如果您从整体上看,如果他们喜欢的话,也可能是那些传播您的应用程序的用户。在广告被阻止的系统上运行的更温和的方法是显示您自己的“自家”广告。创建一张或多张横幅图片,并将其显示在与普通广告相同的位置,并使用相同高度(例如 50dp)的 ImageView。如果您成功收到广告,请将 ImageView 的可见性设置为 View.GONE。您甚至可以创建一个计时器来循环播放多个自家广告以吸引用户的注意力。点击您的广告可以将用户带到市场页面购买完整版本。

As developers, we need to do the difficult job of empathizing with the users and find a middle ground between punishing the few who try to take advantage and the many who play by the rules. Mobile advertising is a reasonable way to allow someone to use a functional piece of software for free. The users who employ ad blocking techniques could be considered lost revenue, but if you take a look at the big picture, can also be those who spread the word about your application if they like it. A more gentle approach to running on systems with ads blocked is to display your own "house" ad. Create one or more banner images and display them in the same spot as your normal ad with an ImageView of the same height (e.g. 50dp). If you successfully receive an ad, then set your ImageView's visibility to View.GONE. You can even create a timer to cycle through several house ads to get the user's attention. Clicking on your ad can take the user to the market page to buy the full version.

旧城空念 2024-09-21 03:19:07

您可以检查广告是否已加载到您的应用中吗?

广告拦截器的工作原理是阻止您的应用程序下载数据。您可以检查广告框中数据的内容长度,以确保其中有数据。

如果没有数据,则会抛出一条消息并退出或通过电子邮件警告您。

这可能不像您想象的那么大,因为只有一小部分人会屏蔽广告。

Can you check to see if the ad loaded in your app?

Ad blockers work by preventing your app from downloading data. You could check the content length of the data in your ad frame to make sure there is data there.

If there is no data throw up a message and exit or warn you with an email.

It might not be as big an issue as you think since only a small percentage of people block ads.

末が日狂欢 2024-09-21 03:19:07

前两个答案仅帮助您使用特定的(如果可能是最流行的)屏蔽广告的方法。 Root 用户还可以使用设备上的防火墙来阻止广告。 WiFi 用户可以使用上游防火墙阻止广告。

我建议:

  1. 不要奖励广告拦截用户。确保您的布局为广告保留部分显示,即使无法加载广告也是如此。或者,如果您有一个播放一段时间的全屏广告,请确保您的应用程序等待一段时间,即使该广告无法播放。如果你把通知当作广告(你就是渣),当你没有收到这样的广告时通知用户。这可以理解为“惹恼您的所有用户”,但您的普通用户知道他们会得到什么,并且不需要您的广告拦截“用户”。

  2. 要求广告拦截器停止。提供用户想要的东西的行业利润越低,该行业提供用户想要的东西的能力就越少。个人开发者会发现他为其他用户提供服务可以赚更多的钱。你知道这一点,并且你的用户在你告诉他们之后会认为这是显而易见的,但这仍然是一个经济论据 - 它不直观。准备一个备用广告,内容如下:“这是我的工作。如果你不付钱给我,我就会再做一份,而且你不会从我这里得到更多这样的应用程序。”

The top two answers help you with only a particular (if, probably, the most popular) method of blocking ads. Root users can also block ads with a firewall on the device. WiFi users can block ads with an upstream firewall.

I suggest:

  1. Don't reward ad-blocking users. Ensure that your layout reserves part of the display for an ad even if one can't be loaded. Or if you have a full-screen ad that plays for a bit, ensure that your app waits for a bit even if the ad can't be played. If you use notifications as adverts (you scum), notify the user when you fail to get such an advert. This could be read as "annoy all of your users", but your normal users know what they're getting, and your ad-blocking 'users' aren't wanted.

  2. Ask ad-blockers to stop. The less proftable an industry that supplies what a user wants, the less that industry will supply what the user had wanted. An individual developer will find that he makes more money serving other users. You know this, and your users will think it obvious after you tell them, but it's still an economic argument - it's not intuitive. Have a backup ad that says something like, "This is my job. If you don't pay me, I'll get another one, and you won't get more apps like this from me."

饮湿 2024-09-21 03:19:07

没有什么是你不能做而你的用户却不能做得更好的。

唯一想到的远程有效的方法是使广告成为程序中不可分割的一部分,这样,如果它们被阻止,用户就无法理解应用程序/与应用程序交互。

There is nothing you can do that your users can't do better.

The only thing that comes to mind as remotely effective is to make the ads an inextricable part of the program, so that if they're blocked the user cannot make sense of/interact with the application.

海未深 2024-09-21 03:19:07

我的方法不是检查已安装或修改的主机文件中的单个软件,而是使用 AdListener 像这样,如果广告由于NETWORK_ERROR而无法加载,我只需获取一些随机的始终在线的内容页面(如需更多信息,请访问 apple.com)并检查页面是否加载成功。

如果是这样,应用程序将会繁荣

要添加一些代码,侦听器类将类似于:

public abstract class AdBlockerListener implements AdListener {

    @Override
    public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
        if (arg1.equals(ErrorCode.NETWORK_ERROR)) {
            try {
                URL url = new URL("http://www.apple.com/");
                URLConnection conn = url.openConnection();
                BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                reader.readLine();
                onAdBlocked();
            } catch (IOException e) {}
        }
    }

    public abstract void onAdBlocked();
}

然后每个具有 adView 的活动都会执行类似以下操作:

AdView adView = (AdView) findViewById(R.id.adView);
        adView.setAdListener(new AdBlockerListener() {
            @Override
            public void onAdBlocked() {
                AlertDialog ad = new AlertDialog.Builder(CalendarView.this)
                                    .setMessage("nono")
                                    .setCancelable(false)
                                    .setNegativeButton("OK", new OnClickListener() {
                                        public void onClick(DialogInterface dialog, int which) {
                                            System.exit(1);
                                        }
                                    })
                                    .show();
            }
        });

Rather than checking for individual software installed or modified hosts file, my approach is using an AdListener like this and, if the ad fails to load due to NETWORK_ERROR, I just fetch some random always-online page (for the kicks, apple.com) and check if the pages loads successfully.

If so, boom goes the app.

To add some code, listener class would be something like:

public abstract class AdBlockerListener implements AdListener {

    @Override
    public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
        if (arg1.equals(ErrorCode.NETWORK_ERROR)) {
            try {
                URL url = new URL("http://www.apple.com/");
                URLConnection conn = url.openConnection();
                BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                reader.readLine();
                onAdBlocked();
            } catch (IOException e) {}
        }
    }

    public abstract void onAdBlocked();
}

And then each activity with an adView would do something like:

AdView adView = (AdView) findViewById(R.id.adView);
        adView.setAdListener(new AdBlockerListener() {
            @Override
            public void onAdBlocked() {
                AlertDialog ad = new AlertDialog.Builder(CalendarView.this)
                                    .setMessage("nono")
                                    .setCancelable(false)
                                    .setNegativeButton("OK", new OnClickListener() {
                                        public void onClick(DialogInterface dialog, int which) {
                                            System.exit(1);
                                        }
                                    })
                                    .show();
            }
        });
如何视而不见 2024-09-21 03:19:07

我认为这取决于广告的内容提供商。我知道 AdMob SDK 在广告请求失败时提供回调。我怀疑您可以注册此操作,然后在回调中检查连接 - 如果有连接并且您没有收到广告 - 请注意,如果这种情况发生超过一次或两次,则很可能是您的广告被屏蔽。我没有使用过 Google 的 AdSense for Mobile 工具集,但如果有类似的回调机制,我也不会感到惊讶。

I think it depends on the content provider for the ads. I know the AdMob SDK provides a callback when an ad request fails. I suspect that you might be able to register for this, then check for a connection in the callback - if there is a connection and you did not receive an ad - take note, if it happens more than once or twice, chances are likely your ads are being blocked. I have not worked with the AdSense for Mobile toolset from Google but it wouldn't surprise me if there was a similar callback mechanism.

嗫嚅 2024-09-21 03:19:07

用户绕过广告的方法有两种:

1)在没有互联网的情况下使用应用程序。

2) 手机已root并修改了hosts文件。

我制作了两个您可以实现的工具,请参阅下面的代码。

检查在线();针对问题1:

public void checkifonline() {
    boolean haveConnectedWifi = false;
    boolean haveConnectedMobile = false;

    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo[] netInfo = cm.getAllNetworkInfo();
    for (NetworkInfo ni : netInfo) {
        if (ni.getTypeName().equalsIgnoreCase("WIFI"))
            if (ni.isConnected())
                haveConnectedWifi = true;
        if (ni.getTypeName().equalsIgnoreCase("MOBILE"))
            if (ni.isConnected())
                haveConnectedMobile = true;
    }

    if(haveConnectedWifi==false && haveConnectedMobile==false){

        // TODO (could make massage and than finish();
    }
}

adblockcheck();用于问题2

private void adblockcheck() {
    BufferedReader in = null;
    boolean result = true;

    try 
    {
        in = new BufferedReader(new InputStreamReader(
                new FileInputStream("/etc/hosts")));
        String line;

        while ((line = in.readLine()) != null)
        {
            if (line.contains("admob"))
            {
                result = false;
                break;
            }
        }
    } catch (UnknownHostException e) { }
      catch (IOException e) {e.printStackTrace();}  

    if(result==false){

        // TODO (could make massage and than finish();

    }
}

There are two ways for a user to by pass a advertisement:

1) Use app without internet on.

2) With rooted phone and modified host file.

I made two tools that you can implement, see code below.

checkifonline(); is for problem 1:

public void checkifonline() {
    boolean haveConnectedWifi = false;
    boolean haveConnectedMobile = false;

    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo[] netInfo = cm.getAllNetworkInfo();
    for (NetworkInfo ni : netInfo) {
        if (ni.getTypeName().equalsIgnoreCase("WIFI"))
            if (ni.isConnected())
                haveConnectedWifi = true;
        if (ni.getTypeName().equalsIgnoreCase("MOBILE"))
            if (ni.isConnected())
                haveConnectedMobile = true;
    }

    if(haveConnectedWifi==false && haveConnectedMobile==false){

        // TODO (could make massage and than finish();
    }
}

adblockcheck(); is for problem 2

private void adblockcheck() {
    BufferedReader in = null;
    boolean result = true;

    try 
    {
        in = new BufferedReader(new InputStreamReader(
                new FileInputStream("/etc/hosts")));
        String line;

        while ((line = in.readLine()) != null)
        {
            if (line.contains("admob"))
            {
                result = false;
                break;
            }
        }
    } catch (UnknownHostException e) { }
      catch (IOException e) {e.printStackTrace();}  

    if(result==false){

        // TODO (could make massage and than finish();

    }
}
紫﹏色ふ单纯 2024-09-21 03:19:07

这是之前答案的延伸。用户告诉我他们正在使用的应用程序称为 AdFree Android。它可以在市场上找到。该应用程序表示,它的工作原理是“取消对已知主机名投放广告的请求”。

我建议,如果您通过广告对任何应用程序进行货币化,请在启动时检查该程序并向用户发出令人讨厌的消息,然后终止您的应用程序。

This is an extension of a previous answer. The user has informed me that the app they are using is called AdFree Android. It can be found on the market. The app says it works by "nullifying requests to known hostnames serving ads."

I suggest that if you monetize any of your apps with ads, you check at startup for this program and give the user a nasty message, then terminate your app.

九公里浅绿 2024-09-21 03:19:07

首先,我想说的是,我认为广告拦截对于应用程序来说实际上是一种盗版形式。这些应用程序由广告支持,有时还需要“付费许可证”来关闭广告和/或添加功能。通过屏蔽广告,用户正在从花时间创建您正在使用的应用程序的开发人员那里窃取潜在收入。

无论如何,我想添加一种方法来帮助防止使用广告拦截器。我使用此方法,如果检测到广告拦截器,则不允许用户使用该应用程序。人们会非常生气,并且会给你很差的评价。但我也在我的应用程序描述中非常明确地指出,如果您有广告拦截器,您将无法使用该应用程序。

我使用包管理器来检查是否安装了特定的包。虽然这不会获得所有的广告拦截器,但如果您保持“最新”一些流行的广告拦截器,您就可以获得大多数广告拦截器。

PackageManager pm = activity.getPackageManager ();
Intent intent = pm.getLaunchIntentForPackage ( "de.ub0r.android.adBlock" );
if ( Reflection.isPackageInstalled ( activity, intent ) ) {
  // they have adblock installed
}

First, let me say that I believe that Ad Blocking, when it comes to applications, is actually a form of piracy. These apps are supported by the ads, and sometimes, a "paid license" to turn off ads and/or add features. By blocking ads, users are stealing potential revenue from the developer that took the time to create the app that you are using.

Anyhow, I want to add a way to help prevent the use of Ad Blockers. I use this method and I do not allow users to use the app if I detect an ad blocker. People get very angry and will give you poor ratings for it. But I also state very clearly in my applications descriptions that you will not be able to use the app if you have an adblocker.

I use the package manager to check if a specific package is installed. While this will not get all of the adblockers, if you keep "up to date" on some of the popular ones, you can get most of them.

PackageManager pm = activity.getPackageManager ();
Intent intent = pm.getLaunchIntentForPackage ( "de.ub0r.android.adBlock" );
if ( Reflection.isPackageInstalled ( activity, intent ) ) {
  // they have adblock installed
}
凹づ凸ル 2024-09-21 03:19:07

我确信这个答案不会完全受到某些开发人员的欢迎,但是请考虑一下,如果您属于这一类别,那么您的应用程序可能不值得存在于应用程序商店中。请注意,这些都可以通过代码更改来实现,不需要黑客或间谍软件之类的行为。

基本上,改变应用程序的经济性。 用户永远是对的 - 这是有史以来最成功的广告公司之一(Google)所采取的态度。如果您的广告被用户屏蔽,那是因为很糟糕,而不是因为广告或广告拦截器很糟糕。

http://books.google.com/books/about/The_User_is_Always_Right.html ?id=gLjPMUjVvs0C

  • 让广告不再那么烦人、不那么刺眼。用户对糟糕/烦人的广告做出反应,并且您的应用程序看起来越糟糕,他们就越有可能放弃它。我不介意应用程序中包含广告,只要它们不会显着妨碍功能即可,甚至更好的是,我喜欢与我相关的广告。 (http://www.nngroup.com/articles/most-hated-advertising -techniques/
  • 要检测广告未加载,无需实施类似之前发帖者提到的间谍软件活动。加载带有确认码的广告,并每隔一段时间插入一条要求确认码的提示。该代码不必很长或烦人,事实上它足以实现具有 3 或 4 个字母/数字的验证码服务。
    (http://textcaptcha.com/api)
  • 除了检测广告加载失败之外,还可以制作更好的广告。不要使用像 mobads 这样的 API(你知道这听起来有多下流吗?暴徒?真的吗?我们是开发者,俄罗斯黑手党吗?),而是与广告公司建立合作伙伴关系,允许你直接从你的应用程序嵌入广告。它将使您的整个应用程序安装起来更大,不,您无法防止手动修改,但上面建议的更改也不能防止这种情况。这将更好地支持您的应用程序的任何付费版本,这将更加轻量级(并且更快)。
  • 彻底审查您向用户展示的广告,对您的广告政策保持公开透明,甚至允许用户检查您的广告和广告来源。我担心广告的主要原因不是因为我讨厌广告,而是因为我担心负责此应用程序的低质量开发人员也会引入病毒或其他恶意软件。要求对已安装的广告拦截器进行例外处理。与 AdBlock 等广告拦截器合作,加入他们的例外列表。如果您是合法的应用程序,这应该不成问题。
    http://www.cio.com/article/699970/ 6_Ways_to_Defend_Against_Drive_by_Downloads?page=1&taxonomyId=3089)

我重申:以上所有更改都是您可以在代码中合法执行的操作,以防止反广告行为。广告被屏蔽主要是出于安全原因和本能反应,有时还有带宽和性能,因此请确保您的广告不会在代码级别引发任何这些问题。

最后,我确实想谈谈 Borealid 所说的话,我在上面重申了这一点;最终,这是一场“猫捉老鼠”的游戏,因为用户对其自己的财产拥有法律上和道德上的最终权力和责任。用户可以做任何事情,包括直接即时修改代码。当然,您可以实施一些限制等,但总有办法解决这个问题。这是 DRM 的最终问题(技术上)(这就是您想要做的)。与其在这款游戏上浪费时间和精力,不如鼓励用户保留广告;它们将成为您最好、最聪明的免费反广告拦截器。

I'm sure this answer won't be entirely popular with certain segments of developers, however consider if you fall into this category that perhaps your app doesn't deserve to exist on the app store. Please note that these are all implementable as code changes, no hackery or spyware like behavior required.

Basically, change the economics of your app. The User is Always Right - this is the attitude taken by one of the most successful advertising companies ever (Google). If your ads are being blocked by users, its because you suck, not because ads or ad-blockers suck.

http://books.google.com/books/about/The_User_is_Always_Right.html?id=gLjPMUjVvs0C

  • Make ads less annoying and in-your-face. Users react to poor/annoying advertisement, and the seedier your app looks and becomes, the more likely they are to ditch it anyways. I don't mind apps with ads in them as long as they aren't significantly impeding the functionality, and even better I like ads which are relevant to me. (http://www.nngroup.com/articles/most-hated-advertising-techniques/)
  • To detect that ads aren't being loaded, its not necessary to implement the spyware like activities mentioned by previous posters. Load an ad that has a confirmation code, and every once in awhile, insert a prompt asking for the confirmation code. The code doesn't have to be long or annoying, in fact it'd be enough to implement a captcha service with 3 or 4 letters/numbers.
    (http://textcaptcha.com/api)
  • In addition to detecting failure of ads to load, make better ads. Instead of using an API like mobads (Do you even realize how seedy that sounds? Mobs? Really? Are we developers, the Russian Mafia?), enter a partnership with an ad company that allows you to embed ads directly from your app. It will make your overall app larger to install, and no, you can't guard against manual modification, but the changes suggested above don't guard against that either. And this will better support any paid versions of your app, which will be much more lightweight (and faster).
  • Thoroughly vet the ads you are displaying to the user, be open and transparent about your ad policies, and even allow users to inspect your ads and ad sources. The primary reason I'm ever concerned about ads is not because I hate ads, but because I worry that the poor quality developer responsible for this app is letting in viruses or other malware as well. Ask that an exception be made to the installed adblocker. Team up with ad blockers like AdBlock to get on their exceptions list. If you are a legit application, this shouldn't be a problem.
    (http://www.cio.com/article/699970/6_Ways_to_Defend_Against_Drive_by_Downloads?page=1&taxonomyId=3089)

I re-iterate: all of the above changes are things you can legitimately do in code to prevent anti-ad behaviors. Ads are blocked for security reasons and visceral reactions, primarily, and sometimes bandwidth and performance, so make sure your ads don't invoke any of these problems, at the code level.

Finally I did want to touch on what Borealid said, which I re-iterated above; in the end it is a 'cat and mouse' game, because the user has ultimate authority and responsibility, both legally and morally, over their own property. A user can do whatever, including directly modify code on the fly. Of course, there are restrictions you can implement etc. but there are always ways to get around the problem. This is the ultimate problem (technically) with DRM (which is what you're trying to do). Rather than waste time and effort on this game, it is better to encourage users to keep ads around; they'll become your best, smartest anti-ad-blockers, for free.

水染的天色ゝ 2024-09-21 03:19:07

对于没有互联网连接的情况,我遵循了这个
教程
我已经构建了一个“网络状态侦听器”,如下所示:

private BroadcastReceiver mConnReceiver = new BroadcastReceiver() 
{
    @Override
    public void onReceive(Context context, Intent intent) 
    {
        boolean noConnectivity = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);

        if (noConnectivity == true)
        {
            Log.d(TAG, "No internet connection");
            image.setVisibility(View.VISIBLE);
        }
        else
        {
            Log.d(TAG, "Interet connection is UP");
            image.setVisibility(View.GONE);
            add.loadAd(new AdRequest());
        }
    }
};

@Override
protected void onCreate(Bundle savedInstanceState)
{
    //other stuff
    private ImageView image = (ImageView) findViewById(R.id.banner_main);
    private AdView add = (AdView) findViewById(R.id.ad_main);
    add.setAdListener(new AdListener());
}

@Override
protected void onResume()
{
    registerReceiver(mConnReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
    super.onResume();
}

@Override
protected void onPause()
{
    unregisterReceiver(mConnReceiver);
    super.onPause();
}

必须分别在 onResume 和 onPause 中调用 registerReceiver 和 unregisterReceiver,如此处所述

在布局 xml 中设置您自己选择的 AdView 和 ImageView,如下所示:

<com.google.ads.AdView xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_alignParentBottom="true"
    android:id="@+id/ad_main"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    googleads:adSize="BANNER"
    googleads:adUnitId="@string/admob_id" />

<ImageView
    android:id="@+id/banner_main"
    android:layout_centerInParent="true"
    android:layout_alignParentBottom="true"
    android:layout_width="379dp"
    android:layout_height="50dp"
    android:visibility="gone"
    android:background="@drawable/banner_en_final" />

现在,只要互联网连接可用,广告就会显示,当互联网连接关闭时,ImageView 将弹出,反之亦然。必须在您希望展示广告的每个活动中执行此操作。

For the case when there is no internet connection, I have followed this
tutorial
and I've build a "network state listener" like so:

private BroadcastReceiver mConnReceiver = new BroadcastReceiver() 
{
    @Override
    public void onReceive(Context context, Intent intent) 
    {
        boolean noConnectivity = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);

        if (noConnectivity == true)
        {
            Log.d(TAG, "No internet connection");
            image.setVisibility(View.VISIBLE);
        }
        else
        {
            Log.d(TAG, "Interet connection is UP");
            image.setVisibility(View.GONE);
            add.loadAd(new AdRequest());
        }
    }
};

@Override
protected void onCreate(Bundle savedInstanceState)
{
    //other stuff
    private ImageView image = (ImageView) findViewById(R.id.banner_main);
    private AdView add = (AdView) findViewById(R.id.ad_main);
    add.setAdListener(new AdListener());
}

@Override
protected void onResume()
{
    registerReceiver(mConnReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
    super.onResume();
}

@Override
protected void onPause()
{
    unregisterReceiver(mConnReceiver);
    super.onPause();
}

registerReceiver and unregisterReceiver have to be called in onResume and onPause respectively, as described here.

In your layout xml set up the AdView and an ImageView of your own choice, like so:

<com.google.ads.AdView xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_alignParentBottom="true"
    android:id="@+id/ad_main"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    googleads:adSize="BANNER"
    googleads:adUnitId="@string/admob_id" />

<ImageView
    android:id="@+id/banner_main"
    android:layout_centerInParent="true"
    android:layout_alignParentBottom="true"
    android:layout_width="379dp"
    android:layout_height="50dp"
    android:visibility="gone"
    android:background="@drawable/banner_en_final" />

Now, whenever the internet connection is available the ad will display and when its off the ImageView will pop-up, and vice-versa. This must be done in every activity in which you want ads to display.

坚持沉默 2024-09-21 03:19:07

除了检查 admob 是否可以解决之外,我所做的就是呈现一个页面,基本上建议我已检测到广告拦截器,声明我了解可能的原因,然后显示我自己的应用程序的一些内置广告并询问其类型支持持续发展。 :)

As well as checking if admob can be resolved, what I do is present a page that basically advises that I have detected an adblocker, state that i understand the possible reasons why, then show some inbuilt ads of my own apps and ask for their kind support for continued development. :)

靖瑶 2024-09-21 03:19:07

为您的用户提供一种在没有广告的情况下使用应用程序的方式。我个人认为广告是我的计算机上可能发生的最烦人的事情之一,如果它能让我免受广告扔到我脸上的侮辱,我会很乐意付费购买应用程序。而且我确信我不是唯一一个。

Give your users a way to use the app without the ads. I personally find ads one of the most annoying things that could possibly happen on my computer, and I will gladly pay for an application if it spares me the insult of having ads thrown into my face. And I'm sure I'm not the only one.

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