Skip to content

Instantly share code, notes, and snippets.

@yonekawa
Created May 7, 2014 08:45
Show Gist options
  • Save yonekawa/57d44a440b798b25b32d to your computer and use it in GitHub Desktop.
Save yonekawa/57d44a440b798b25b32d to your computer and use it in GitHub Desktop.
AttributionIdentifiers without facebook app
diff --git a/facebook/src/com/facebook/internal/AttributionIdentifiers.java b/facebook/src/com/facebook/internal/AttributionIdentifiers.java
index 1c8f630..f142f25 100644
--- a/facebook/src/com/facebook/internal/AttributionIdentifiers.java
+++ b/facebook/src/com/facebook/internal/AttributionIdentifiers.java
@@ -104,25 +104,23 @@ public class AttributionIdentifiers {
try {
String [] projection = {ATTRIBUTION_ID_COLUMN_NAME, ANDROID_ID_COLUMN_NAME, LIMIT_TRACKING_COLUMN_NAME};
Cursor c = context.getContentResolver().query(ATTRIBUTION_ID_CONTENT_URI, projection, null, null, null);
- if (c == null || !c.moveToFirst()) {
- return null;
+ if (c != null && c.moveToFirst()) {
+ int attributionColumnIndex = c.getColumnIndex(ATTRIBUTION_ID_COLUMN_NAME);
+ int androidIdColumnIndex = c.getColumnIndex(ANDROID_ID_COLUMN_NAME);
+ int limitTrackingColumnIndex = c.getColumnIndex(LIMIT_TRACKING_COLUMN_NAME);
+
+ identifiers.attributionId = c.getString(attributionColumnIndex);
+
+ // if we failed to call Google's APIs directly (due to improper integration by the client), it may be
+ // possible for the local facebook application to relay it to us.
+ if (androidIdColumnIndex > 0 && limitTrackingColumnIndex > 0 && identifiers.getAndroidAdvertiserId() == null) {
+ identifiers.androidAdvertiserId = c.getString(androidIdColumnIndex);
+ identifiers.limitTracking = Boolean.parseBoolean(c.getString(limitTrackingColumnIndex));
+ }
+ c.close();
}
- int attributionColumnIndex = c.getColumnIndex(ATTRIBUTION_ID_COLUMN_NAME);
- int androidIdColumnIndex = c.getColumnIndex(ANDROID_ID_COLUMN_NAME);
- int limitTrackingColumnIndex = c.getColumnIndex(LIMIT_TRACKING_COLUMN_NAME);
-
- identifiers.attributionId = c.getString(attributionColumnIndex);
-
- // if we failed to call Google's APIs directly (due to improper integration by the client), it may be
- // possible for the local facebook application to relay it to us.
- if (androidIdColumnIndex > 0 && limitTrackingColumnIndex > 0 && identifiers.getAndroidAdvertiserId() == null) {
- identifiers.androidAdvertiserId = c.getString(androidIdColumnIndex);
- identifiers.limitTracking = Boolean.parseBoolean(c.getString(limitTrackingColumnIndex));
- }
- c.close();
} catch (Exception e) {
Log.d(TAG, "Caught unexpected exception in getAttributionId(): " + e.toString());
- return null;
}
identifiers.fetchTime = System.currentTimeMillis();
@@ -141,4 +139,4 @@ public class AttributionIdentifiers {
public boolean isTrackingLimited() {
return limitTracking;
}
-}
\ No newline at end of file
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment