How to programmatically get the Device ID for Admob?(如何以编程方式获取 Admob 的设备 ID?)
问题描述
我有多个设备,我可能会有更多,并且不想一个一个添加它们.有人知道 Admob 使用什么 ID?
I have multiple devices, and I probably will have more, and do not want to add them one by one. Does anybody know what ID Admob uses?
推荐答案
String aid = Settings.Secure.getString(getContext().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);
}
希望对你有帮助;)
这篇关于如何以编程方式获取 Admob 的设备 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!