0

我总是得到 admobs 的测试添加。即使我正在为 setTestDevices 设置设备 ID,我也没有看到任何真正的添加,而且我尝试了 addTestDevices 也请帮助我提前谢谢,这是我的代码..

    HashSet<String> hsDevice =  new HashSet<String>();
hsDevice.add(getDeviceIDforAdMob());
adRequest.setTestDevices(hsDevice);
DfpAdView adView = new DfpAdView(Base.this, AdSize.BANNER, baneerID);                   
    adView.loadAd(adRequest);

    public String getDeviceIDforAdMob()
    {
      String aid = Settings.Secure.getString(Base.this.getContentResolver(), "android_id");

     Object obj = null;
      try 
      {
         ((MessageDigest) (obj = MessageDigest.getInstance("MD5"))).update( aid.getBytes(), 0, aid.length());
         obj = String.format("%032X", new Object[] { new BigInteger(1,((MessageDigest) obj).digest()) });
      }
      catch (NoSuchAlgorithmException localNoSuchAlgorithmException) 
      {
        obj = aid.substring(0, 32);
      }
      return (String) obj;
    }
4

1 回答 1

0

要获得真正的广告,请删除 adRequest.setTestDevices(hsDevice); 从你的代码。

它仅用于开发目的,以便为您提供占位符广告,以免您不小心点击它们。请参阅https://developers.google.com/mobile-ads-sdk/docs/admob/best-practices

于 2013-03-11T20:10:31.470 回答