本文整理汇总了Java中com.google.android.gms.ads.identifier.AdvertisingIdClient.Info方法的典型用法代码示例。如果您正苦于以下问题:Java AdvertisingIdClient.Info方法的具体用法?Java AdvertisingIdClient.Info怎么用?Java AdvertisingIdClient.Info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.ads.identifier.AdvertisingIdClient
的用法示例。
在下文中一共展示了AdvertisingIdClient.Info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onFetchCurrentLocation
import com.google.android.gms.ads.identifier.AdvertisingIdClient; //导入方法依赖的package包/类
private void onFetchCurrentLocation(final Location location, final OpenLocateLocationCallback callback) {
FetchAdvertisingInfoTask task = new FetchAdvertisingInfoTask(context, new FetchAdvertisingInfoTaskCallback() {
@Override
public void onAdvertisingInfoTaskExecute(AdvertisingIdClient.Info info) {
callback.onLocationFetch(
OpenLocateLocation.from(
location,
info,
InformationFieldsFactory.collectInformationFields(context, configuration)
)
);
}
});
task.execute();
}
示例2: getAdvertisingId
import com.google.android.gms.ads.identifier.AdvertisingIdClient; //导入方法依赖的package包/类
/**
* Retrieves the advertising ID. Requires Google Play Services. Note: This method must not run on
* the main thread.
*/
private static DeviceIdInfo getAdvertisingId(Context caller) throws Exception {
try {
AdvertisingIdClient.Info info = AdvertisingIdClient.getAdvertisingIdInfo(caller);
if (info != null) {
String advertisingId = info.getId();
String deviceId = checkDeviceId("advertising id", advertisingId);
if (deviceId != null) {
boolean limitedTracking = info.isLimitAdTrackingEnabled();
return new DeviceIdInfo(deviceId, limitedTracking);
}
}
} catch (Throwable t) {
Log.e("Error getting advertising ID. Google Play Services are not available: ", t);
}
return null;
}
示例3: setValues
import com.google.android.gms.ads.identifier.AdvertisingIdClient; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void setValues(Intent intent) {
endpoints = intent.getParcelableArrayListExtra(Constants.ENDPOINTS_KEY);
advertisingInfo = new AdvertisingIdClient.Info(
intent.getStringExtra(Constants.ADVERTISING_ID_KEY),
intent.getBooleanExtra(Constants.LIMITED_AD_TRACKING_ENABLED_KEY, false)
);
setLocationRequestIntervalInSecs(intent);
setTransmissionIntervalInSecs(intent);
setLocationAccuracy(intent);
setFieldsConfiguration(intent);
}
示例4: zzCw
import com.google.android.gms.ads.identifier.AdvertisingIdClient; //导入方法依赖的package包/类
final Pair<String, Boolean> zzCw()
{
checkOnWorkerThread();
long l = getClock().elapsedRealtime();
if ((this.zzbnx != null) && (l < this.zzbnz)) {
return new Pair(this.zzbnx, Boolean.valueOf(this.zzbny));
}
this.zzbnz = (l + zzc.zzBG());
AdvertisingIdClient.setShouldSkipGmsCoreVersionCheck(true);
try
{
AdvertisingIdClient.Info localInfo = AdvertisingIdClient.getAdvertisingIdInfo(getContext());
this.zzbnx = localInfo.zzpp;
this.zzbny = localInfo.zzpq;
AdvertisingIdClient.setShouldSkipGmsCoreVersionCheck(false);
return new Pair(this.zzbnx, Boolean.valueOf(this.zzbny));
}
catch (Throwable localThrowable)
{
for (;;)
{
zzBh().zzbnd.zzm("Unable to get advertising id", localThrowable);
this.zzbnx = "";
}
}
}
示例5: getDumpMap
import com.google.android.gms.ads.identifier.AdvertisingIdClient; //导入方法依赖的package包/类
@Override
public LinkedHashMap<String, String> getDumpMap(Context context) throws DumpException {
LinkedHashMap<String, String> dumps = new LinkedHashMap<>();
dumps.put(Settings.Secure.ANDROID_ID, getAndroidId(context));
dumps.put("UUID", getUUID());
String adIdKey = "AdvertisingId";
String adOptoutKey = "isAdOptout";
AdvertisingIdClient.Info adInfo = getAdInfo(context);
if (adInfo == null) {
dumps.put(adIdKey, "Getting AdvertisingId need a android.permission.INTERNET");
dumps.put(adOptoutKey, "Getting AdvertisingId need a android.permission.INTERNET");
} else {
dumps.put(adIdKey, adInfo.getId());
dumps.put(adOptoutKey, Boolean.toString(adInfo.isLimitAdTrackingEnabled()));
}
return dumps;
}
示例6: updateAdvertisingId
import com.google.android.gms.ads.identifier.AdvertisingIdClient; //导入方法依赖的package包/类
public void updateAdvertisingId() {
new Thread(new Runnable() {
@Override
public void run() {
AdvertisingIdClient.Info adInfo = null;
try {
adInfo = AdvertisingIdClient.getAdvertisingIdInfo(TweetingActivity.this);
} catch (IOException | GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException exception) {
// Unrecoverable error connecting to Google Play services (e.g.,
// the old version of the service doesn't support getting AdvertisingId).
}
if (adInfo != null) {
mAdversitingId = adInfo.getId();
}
}
});
}
示例7: OpenLocateLocation
import com.google.android.gms.ads.identifier.AdvertisingIdClient; //导入方法依赖的package包/类
OpenLocateLocation(
Location location,
AdvertisingIdClient.Info advertisingInfo, InformationFields informationFields) {
this.location = new LocationInfo(location);
this.advertisingInfo = advertisingInfo;
this.informationFields = informationFields;
this.created = new Date();
}
示例8: onPermissionsGranted
import com.google.android.gms.ads.identifier.AdvertisingIdClient; //导入方法依赖的package包/类
void onPermissionsGranted() {
FetchAdvertisingInfoTask task = new FetchAdvertisingInfoTask(context, new FetchAdvertisingInfoTaskCallback() {
@Override
public void onAdvertisingInfoTaskExecute(AdvertisingIdClient.Info info) {
onFetchAdvertisingInfo(info);
}
});
task.execute();
}
示例9: onFetchAdvertisingInfo
import com.google.android.gms.ads.identifier.AdvertisingIdClient; //导入方法依赖的package包/类
private void onFetchAdvertisingInfo(AdvertisingIdClient.Info info) {
Intent intent = new Intent(context, LocationService.class);
intent.putParcelableArrayListExtra(Constants.ENDPOINTS_KEY, endpoints);
updateLocationConfigurationInfo(intent);
updateFieldsConfigurationInfo(intent);
if (info != null) {
updateAdvertisingInfo(intent, info.getId(), info.isLimitAdTrackingEnabled());
}
context.startService(intent);
setStartedPreferences();
}
示例10: testFetchAdvertisingInfoTask
import com.google.android.gms.ads.identifier.AdvertisingIdClient; //导入方法依赖的package包/类
@Test
public void testFetchAdvertisingInfoTask() {
// Given
final Object syncObject = new Object();
FetchAdvertisingInfoTaskCallback callback = new FetchAdvertisingInfoTaskCallback() {
@Override
public void onAdvertisingInfoTaskExecute(AdvertisingIdClient.Info advertisingInfo) {
assertNotNull(advertisingInfo);
synchronized (syncObject) {
syncObject.notify();
}
}
};
FetchAdvertisingInfoTask task = new FetchAdvertisingInfoTask(InstrumentationRegistry.getTargetContext(), callback);
// When
task.execute();
// Then
synchronized (syncObject) {
try {
syncObject.wait();
} catch (InterruptedException e) {
assertTrue(false);
}
}
}
示例11: testOpenLocateConstructor
import com.google.android.gms.ads.identifier.AdvertisingIdClient; //导入方法依赖的package包/类
@Test
public void testOpenLocateConstructor() {
// Given
double lat = 10.40;
double lng = 10.234;
double accuracy = 40.43;
boolean adOptOut = true;
String adId = "1234";
Location location = new Location("");
location.setLatitude(lat);
location.setLongitude(lng);
location.setAccuracy((float) accuracy);
AdvertisingIdClient.Info info = new AdvertisingIdClient.Info(adId, adOptOut);
OpenLocateLocation openLocateLocation = new OpenLocateLocation(location, info, null);
// When
JSONObject json = openLocateLocation.getJson();
// Then
assertNotNull(openLocateLocation);
try {
assertEquals(json.getDouble(OpenLocateLocation.Keys.LATITUDE), lat, 0.0d);
assertEquals(json.getDouble(OpenLocateLocation.Keys.LONGITUDE), lng, 0.0d);
assertEquals(json.getDouble(OpenLocateLocation.Keys.HORIZONTAL_ACCURACY), accuracy, 0.1);
assertEquals(json.getBoolean(OpenLocateLocation.Keys.AD_OPT_OUT), adOptOut);
assertEquals(json.getString(OpenLocateLocation.Keys.AD_ID), adId);
} catch (JSONException e) {
e.printStackTrace();
}
}
示例12: doInBackground
import com.google.android.gms.ads.identifier.AdvertisingIdClient; //导入方法依赖的package包/类
@Override
protected String doInBackground(Void... params) {
try {
AdvertisingIdClient.Info info = AdvertisingIdClient.getAdvertisingIdInfo(mContext);
success = true;
return info.getId();
} catch (IOException | GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException e) {
e.printStackTrace();
success = false;
return e.getMessage();
}
}
示例13: zzZ
import com.google.android.gms.ads.identifier.AdvertisingIdClient; //导入方法依赖的package包/类
private zza zzZ()
throws IOException
{
try
{
if (!zznX.await(2L, TimeUnit.SECONDS))
{
zza localzza1 = new zza(null, false);
return localzza1;
}
}
catch (InterruptedException localInterruptedException)
{
return new zza(null, false);
}
try
{
if (zznW == null)
{
zza localzza2 = new zza(null, false);
return localzza2;
}
}
finally {}
AdvertisingIdClient.Info localInfo = zznW.getInfo();
return new zza(zzk(localInfo.zzpp), localInfo.zzpq);
}
示例14: f
import com.google.android.gms.ads.identifier.AdvertisingIdClient; //导入方法依赖的package包/类
a f(Context paramContext)
{
AdvertisingIdClient.Info localInfo;
try
{
localInfo = AdvertisingIdClient.getAdvertisingIdInfo(paramContext);
}
catch (GooglePlayServicesRepairableException localGooglePlayServicesRepairableException)
{
throw new IOException(localGooglePlayServicesRepairableException);
}
String str1 = localInfo.getId();
String str2 = str1;
if ((str1 != null) && (str2.matches("^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$")))
{
byte[] arrayOfByte = new byte[16];
int i = 0;
for (int j = 0; j < str2.length(); j += 2)
{
if ((j == 8) || (j == 13) || (j == 18) || (j == 23))
j++;
arrayOfByte[i] = ((byte)((Character.digit(str2.charAt(j), 16) << 4) + Character.digit(str2.charAt(j + 1), 16)));
i++;
}
str2 = this.dw.a(arrayOfByte, true);
}
return new a(str2, localInfo.isLimitAdTrackingEnabled());
}
示例15: getAdvertisingInfo
import com.google.android.gms.ads.identifier.AdvertisingIdClient; //导入方法依赖的package包/类
public AdvertisingIdClient.Info getAdvertisingInfo() {
return advertisingInfo;
}