Android Interstitial ads add test device?

こ雲淡風輕ζ 提交于 2019-11-30 17:11:08

问题


You can easily add test devices with banner ads so you don't get banned by accidentally clicking on them. However I cannot find how to add test devices to interstitial ads. I assume you also can be banned if you click accidentally on them.

Can you add test devices to these and if so, how? I can't find it on the official google guide, nor on SA. How to get test ad Banners and test Interstitial ads working for adMob? did look promising, but there was no answer on how to add test devices.


回答1:


Can you add test devices to these and if so, how?

So here you go:

// request test interstitial ads
        AdRequest adRequestInterstitial = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .addTestDevice(testDeviceId)
            .build();

// request test banner ads
  AdRequest adRequestBanner = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .addTestDevice(testDeviceId)
            .build();



回答2:


I use the admob test ads id:

  1. For banner: ca-app-pub-3940256099942544/6300978111
  2. For Interstitial : ca-app-pub-3940256099942544/1033173712

Refer: link




回答3:


A small hack & its done.....! I have write few lines of code ,which will add every device as a test_device ,When you run your app in it .

Just Write this code before loading the add:

SharedPreferences var1 = context.getSharedPreferences("FBAdPrefs", 0);
        String i = u.b(UUID.randomUUID().toString());
        if (!var1.getString("deviceIdHash", "").equals(i))
        {
            var1.edit().putString("deviceIdHash", i).apply();
        }

        AdSettings.addTestDevice(i);

It works for all type of facebook ad's ..!



来源:https://stackoverflow.com/questions/21663618/android-interstitial-ads-add-test-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!