Skip to content

Instantly share code, notes, and snippets.

@SauloSilva
Created July 2, 2014 19:22
Show Gist options
  • Save SauloSilva/c8f047ade794653d7d35 to your computer and use it in GitHub Desktop.
Save SauloSilva/c8f047ade794653d7d35 to your computer and use it in GitHub Desktop.
Ads google tester
// md5
package br.com.clickjogos.utils;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class Md5 {
public Md5() {}
public String generate(final String s) {
try {
MessageDigest digest = java.security.MessageDigest
.getInstance("MD5");
digest.update(s.getBytes());
byte messageDigest[] = digest.digest();
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) {}
return "";
}
}
// request
private String mAndroidId;
String androidId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
Md5 md5 = new Md5();
mAndroidId = md5.generate(androidId).toUpperCase();
if (BuildConfig.DEBUG) {
adRequest
.addTestDevice(PublisherAdRequest.DEVICE_ID_EMULATOR)
.addTestDevice(mAndroidId);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment