Object experimentObject = e.getValue(); Invocation experiment = Invocation.fromObject(experimentObject); String testName = experiment.invokeStringMethod("getTestName"); String enrolledVariantName = experiment.invokeStringMethod("getEnrolledVariantName");
private static @Nullable AdvertisingIdClientInfo resolveAdvertisingIdClientInfo(Context context) { try { Invocation advertisingIdClient = Invocation.fromClass(CLASS_ADVERTISING_ID_CLIENT); Object infoObject = advertisingIdClient.invokeMethod(METHOD_GET_ADVERTISING_ID_INFO, new Class<?>[] { Context.class }, new Object[] { context }); if (infoObject == null) { ApptentiveLog.w("Unable to resolve advertising ID: '%s' did not return a valid value", METHOD_GET_ADVERTISING_ID_INFO); return null; } Invocation info = Invocation.fromObject(infoObject); String id = info.invokeStringMethod(METHOD_GET_ID); boolean limitAdTrackingEnabled = info.invokeBooleanMethod(METHOD_IS_LIMIT_AD_TRACKING_ENABLED); return new AdvertisingIdClientInfo(id, limitAdTrackingEnabled); } catch (Exception e) { Throwable cause = e.getCause(); if (cause != null) { if (StringUtils.equal(cause.getClass().getSimpleName(), "GooglePlayServicesNotAvailableException")) { ApptentiveLog.e(e, "Unable to resolve advertising ID: Google Play is not installed on this device"); return null; } if (StringUtils.equal(cause.getClass().getSimpleName(), "GooglePlayServicesRepairableException")) { ApptentiveLog.e(e, "Unable to resolve advertising ID: error connecting to Google Play Services"); return null; } } ApptentiveLog.e(e, "Unable to resolve advertising ID"); logException(e); return null; } }