是否有admob间质视频广告的测试标识?
我知道横幅和图像间的虚拟测试id。
横幅: ca-app-pub-3940256099942544/6300978111 Interstitial:ca-app-pub-3940256099942544/1033173712
我需要视频间的虚拟测试id
我已经知道如何添加测试设备id了。
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("TEST_DEVICE_ID")
.build();
adView.loadAd(adRequest);但我想给另一个人演示一下,他的设备身份不明
所以有人能给我
视频间的测试id
提前感谢
发布于 2016-11-11 07:25:26
如下所示:How can I get device ID for Admob
可以以编程方式将当前正在运行的设备设置为adview测试设备。
if(YourApplication.debugEnabled(this)) //debug flag from somewhere that you set
{
String android_id = Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID);
String deviceId = md5(android_id).toUpperCase();
mAdRequest.addTestDevice(deviceId);
boolean isTestDevice = mAdRequest.isTestDevice(this);
Log.v(TAG, "is Admob Test Device ? "+deviceId+" "+isTestDevice); //to confirm it worked
}您需要使用Android的md5,并且它需要大写。下面是我使用的md5代码
public static final String md5(final String s) {
try {
// Create MD5 Hash
MessageDigest digest = java.security.MessageDigest
.getInstance("MD5");
digest.update(s.getBytes());
byte messageDigest[] = digest.digest();
// Create Hex String
StringBuffer hexString = new StringBuffer();
for (int i = 0; i < messageDigest.length; i++) {
String h = Integer.toHexString(0xFF & messageDigest[i]);
while (h.length() < 2)
h = "0" + h;
hexString.append(h);
}
return hexString.toString();
} catch (NoSuchAlgorithmException e) {
Logger.logStackTrace(TAG,e);
}
return "";
}https://stackoverflow.com/questions/40542999
复制相似问题