Java Code Examples for com.google.android.gms.ads.identifier.AdvertisingIdClient#Info
The following examples show how to use
com.google.android.gms.ads.identifier.AdvertisingIdClient#Info .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocationUpdatesBroadcastReceiver.java From openlocate-android with MIT License | 6 votes |
private void processLocations(List<Location> locations, Context context, OpenLocate.Configuration configuration, AdvertisingIdClient.Info advertisingIdInfo) { LocationDatabase locationsDatabase = new LocationDatabase(DatabaseHelper.getInstance(context)); try { for (Location location : locations) { Log.v(TAG, location.toString()); OpenLocateLocation olLocation = OpenLocateLocation.from( location, advertisingIdInfo, InformationFieldsFactory.collectInformationFields(context, configuration) ); locationsDatabase.add(olLocation); } } catch (SQLiteFullException exception) { Log.w(TAG, "Database is full. Cannot add data."); } finally { locationsDatabase.close(); } }
Example 2
Source File: IDFA.java From react-native-idfa with MIT License | 6 votes |
@ReactMethod public void getIDFA(Promise promise) { try { AdvertisingIdClient.Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(this.getReactApplicationContext()); String adId = null; if (adInfo.isLimitAdTrackingEnabled()) { adId = ""; } else { adId = adInfo != null ? adInfo.getId() : ""; } promise.resolve(adId); } catch (Exception e) { promise.reject(e); } }
Example 3
Source File: OpenLocateLocation.java From openlocate-android with MIT License | 5 votes |
OpenLocateLocation( Location location, AdvertisingIdClient.Info advertisingInfo, InformationFields informationFields) { this.location = new LocationInfo(location); this.advertisingInfo = advertisingInfo; this.informationFields = informationFields; this.created = new Date(); }
Example 4
Source File: OpenLocate.java From openlocate-android with MIT License | 5 votes |
private void onPermissionsGranted() { FetchAdvertisingInfoTask task = new FetchAdvertisingInfoTask(context, new FetchAdvertisingInfoTaskCallback() { @Override public void onAdvertisingInfoTaskExecute(AdvertisingIdClient.Info info) { advertisingIdInfo = info; openLocateHelper.startTracking(); } }); task.execute(); }
Example 5
Source File: FetchAdvertisingInfoTaskTests.java From openlocate-android with MIT License | 5 votes |
@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); } } }
Example 6
Source File: OpenLocateLocationTests.java From openlocate-android with MIT License | 5 votes |
@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(); } }
Example 7
Source File: OpenLocateLocation.java From openlocate-android with MIT License | 4 votes |
public AdvertisingIdClient.Info getAdvertisingInfo() { return advertisingInfo; }
Example 8
Source File: OpenLocateLocation.java From openlocate-android with MIT License | 4 votes |
public void setAdvertisingInfo(AdvertisingIdClient.Info advertisingInfo) { this.advertisingInfo = advertisingInfo; }
Example 9
Source File: OpenLocateLocation.java From openlocate-android with MIT License | 4 votes |
public static OpenLocateLocation from(Location location, AdvertisingIdClient.Info advertisingInfo, InformationFields informationFields) { return new OpenLocateLocation(location, advertisingInfo, informationFields); }
Example 10
Source File: OpenLocateLocation.java From openlocate-android with MIT License | 4 votes |
OpenLocateLocation(Date created, String jsonString) { this.created = created; try { JSONObject json = new JSONObject(jsonString); location = new LocationInfo(); location.setLatitude(json.getDouble(Keys.LATITUDE)); location.setLongitude(json.getDouble(Keys.LONGITUDE)); location.setHorizontalAccuracy(Float.parseFloat(json.getString(Keys.HORIZONTAL_ACCURACY))); location.setTimeStampSecs(json.getLong(Keys.TIMESTAMP)); location.setAltitude(json.getDouble(Keys.ALTITUDE)); location.setCourse(Float.parseFloat(json.getString(Keys.COURSE))); location.setSpeed(Float.parseFloat(json.getString(Keys.SPEED))); try { location.setVerticalAccuracy(Float.parseFloat(json.getString(Keys.VERTICAL_ACCURACY))); } catch (JSONException e) { location.setVerticalAccuracy(0); } String deviceManufacturer = ""; if (json.has(Keys.DEVICE_MANUFACTURER)) { deviceManufacturer = json.getString(Keys.DEVICE_MANUFACTURER); } String deviceModel = ""; if (json.has(Keys.DEVICE_MODEL)) { deviceModel = json.getString(Keys.DEVICE_MODEL); } String chargingState = ""; if (json.has(Keys.IS_CHARGING)) { chargingState = json.getString(Keys.IS_CHARGING); } String operatingSystem = ""; if (json.has(Keys.OPERATING_SYSTEM)) { operatingSystem = json.getString(Keys.OPERATING_SYSTEM); } String carrierName = ""; if (json.has(Keys.CARRIER_NAME)) { carrierName = json.getString(Keys.CARRIER_NAME); } String wifiSSID = ""; if (json.has(Keys.WIFI_SSID)) { wifiSSID = json.getString(Keys.WIFI_SSID); } String wifiBSSID = ""; if (json.has(Keys.WIFI_BSSID)) { wifiBSSID = json.getString(Keys.WIFI_BSSID); } String connectionType = ""; if (json.has(Keys.CONNECTION_TYPE)) { connectionType = json.getString(Keys.CONNECTION_TYPE); } String locationMethod = ""; if (json.has(Keys.LOCATION_METHOD)) { locationMethod = json.getString(Keys.LOCATION_METHOD); } String locationContext = ""; if (json.has(Keys.LOCATION_CONTEXT)) { locationContext = json.getString(Keys.LOCATION_CONTEXT); } informationFields = InformationFieldsFactory.getInformationFields(deviceManufacturer, deviceModel, chargingState, operatingSystem, carrierName, wifiSSID, wifiBSSID, connectionType, locationMethod, locationContext); advertisingInfo = new AdvertisingIdClient.Info( json.getString(Keys.AD_ID), json.getBoolean(Keys.AD_OPT_OUT) ); } catch (JSONException exception) { exception.printStackTrace(); } }
Example 11
Source File: OpenLocate.java From openlocate-android with MIT License | 4 votes |
protected AdvertisingIdClient.Info getAdvertisingIdInfo() { return advertisingIdInfo; }
Example 12
Source File: FetchAdvertisingInfoTaskCallback.java From openlocate-android with MIT License | votes |
void onAdvertisingInfoTaskExecute(AdvertisingIdClient.Info advertisingInfo);