gpt4 book ai didi

android - Admob 视频插页式测试/虚拟 ID

转载 作者:行者123 更新时间:2023-11-30 00:53:36 25 4
gpt4 key购买 nike

是否有 admob 插屏视频广告的测试 ID?

我知道横幅和图像插页式广告的虚拟测试 ID

Banner : 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未知的人演示

谁能给我一个

视频插播的测试 id

提前致谢

最佳答案

正如这里的回答: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 ID的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 "";
}

关于android - Admob 视频插页式测试/虚拟 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40542999/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com