Created
July 2, 2014 19:22
-
-
Save SauloSilva/c8f047ade794653d7d35 to your computer and use it in GitHub Desktop.
Ads google tester
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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