我总是为测试添加测试。我没有看到任何真正的添加,即使我为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;
}
答案 0 :(得分:0)
要获得真实广告,请删除adRequest.setTestDevices(hsDevice);从你的代码。
它的开发目的只是为了获取占位符广告,以免您不小心点击它们。 见https://developers.google.com/mobile-ads-sdk/docs/admob/best-practices