当前位置: 首页>>代码示例>>Java>>正文


Java AttributionIdentifiers.getAndroidAdvertiserId方法代码示例

本文整理汇总了Java中com.facebook.internal.AttributionIdentifiers.getAndroidAdvertiserId方法的典型用法代码示例。如果您正苦于以下问题:Java AttributionIdentifiers.getAndroidAdvertiserId方法的具体用法?Java AttributionIdentifiers.getAndroidAdvertiserId怎么用?Java AttributionIdentifiers.getAndroidAdvertiserId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.internal.AttributionIdentifiers的用法示例。


在下文中一共展示了AttributionIdentifiers.getAndroidAdvertiserId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newCustomAudienceThirdPartyIdRequest

import com.facebook.internal.AttributionIdentifiers; //导入方法依赖的package包/类
public static Request newCustomAudienceThirdPartyIdRequest(Session paramSession, Context paramContext, String paramString, Callback paramCallback)
{
  if (paramSession == null)
    paramSession = Session.getActiveSession();
  if ((paramSession != null) && (!paramSession.isOpened()))
    paramSession = null;
  if (paramString == null)
    if (paramSession != null)
      paramString = paramSession.getApplicationId();
    else
      paramString = Utility.getMetadataApplicationId(paramContext);
  if (paramString == null)
    throw new FacebookException("Facebook App ID cannot be determined");
  String str1 = paramString + "/custom_audience_third_party_id";
  AttributionIdentifiers localAttributionIdentifiers = AttributionIdentifiers.getAttributionIdentifiers(paramContext);
  Bundle localBundle = new Bundle();
  if (paramSession == null)
  {
    String str2;
    if (localAttributionIdentifiers.getAttributionId() != null)
      str2 = localAttributionIdentifiers.getAttributionId();
    else
      str2 = localAttributionIdentifiers.getAndroidAdvertiserId();
    if (localAttributionIdentifiers.getAttributionId() != null)
      localBundle.putString("udid", str2);
  }
  if ((Settings.getLimitEventAndDataUsage(paramContext)) || (localAttributionIdentifiers.isTrackingLimited()))
    localBundle.putString("limit_event_usage", "1");
  HttpMethod localHttpMethod = HttpMethod.GET;
  return new Request(paramSession, str1, localBundle, localHttpMethod, paramCallback);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:32,代码来源:Request.java

示例2: publishInstallAndWaitForResponse

import com.facebook.internal.AttributionIdentifiers; //导入方法依赖的package包/类
static Response publishInstallAndWaitForResponse(
        final Context context,
        final String applicationId,
        final boolean isAutoPublish) {
    try {
        if (context == null || applicationId == null) {
            throw new IllegalArgumentException("Both context and applicationId must be non-null");
        }
        AttributionIdentifiers identifiers = AttributionIdentifiers.getAttributionIdentifiers(context);
        SharedPreferences preferences = context.getSharedPreferences(ATTRIBUTION_PREFERENCES, Context.MODE_PRIVATE);
        String pingKey = applicationId+"ping";
        String jsonKey = applicationId+"json";
        long lastPing = preferences.getLong(pingKey, 0);
        String lastResponseJSON = preferences.getString(jsonKey, null);

        // prevent auto publish from occurring if we have an explicit call.
        if (!isAutoPublish) {
            setShouldAutoPublishInstall(false);
        }

        GraphObject publishParams = GraphObject.Factory.create();
        publishParams.setProperty(ANALYTICS_EVENT, MOBILE_INSTALL_EVENT);

        Utility.setAppEventAttributionParameters(publishParams,
                identifiers,
                Utility.getHashedDeviceAndAppID(context, applicationId),
                getLimitEventAndDataUsage(context));
        publishParams.setProperty(AUTO_PUBLISH, isAutoPublish);
        publishParams.setProperty("application_package_name", context.getPackageName());

        String publishUrl = String.format(PUBLISH_ACTIVITY_PATH, applicationId);
        Request publishRequest = Request.newPostRequest(null, publishUrl, publishParams, null);

        if (lastPing != 0) {
            GraphObject graphObject = null;
            try {
                if (lastResponseJSON != null) {
                    graphObject = GraphObject.Factory.create(new JSONObject(lastResponseJSON));
                }
            }
            catch (JSONException je) {
                // return the default graph object if there is any problem reading the data.
            }
            if (graphObject == null) {
                return Response.createResponsesFromString("true", null, new RequestBatch(publishRequest), true).get(0);
            } else {
                return new Response(null, null, null, graphObject, true);
            }
        } else if (identifiers.getAndroidAdvertiserId() == null && identifiers.getAttributionId() == null) {
            throw new FacebookException("No attribution id available to send to server.");
        } else {
            if (!Utility.queryAppSettings(applicationId, false).supportsAttribution()) {
                throw new FacebookException("Install attribution has been disabled on the server.");
            }

            Response publishResponse = publishRequest.executeAndWait();

            // denote success since no error threw from the post.
            SharedPreferences.Editor editor = preferences.edit();
            lastPing = System.currentTimeMillis();
            editor.putLong(pingKey, lastPing);

            // if we got an object response back, cache the string of the JSON.
            if (publishResponse.getGraphObject() != null &&
                publishResponse.getGraphObject().getInnerJSONObject() != null) {
                editor.putString(jsonKey, publishResponse.getGraphObject().getInnerJSONObject().toString());
            }
            editor.commit();

            return publishResponse;
        }
    } catch (Exception e) {
        // if there was an error, fall through to the failure case.
        Utility.logd("Facebook-publish", e);
        return new Response(null, null, new FacebookRequestError(null, e));
    }
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:78,代码来源:Settings.java

示例3: publishInstallAndWaitForResponse

import com.facebook.internal.AttributionIdentifiers; //导入方法依赖的package包/类
static Response publishInstallAndWaitForResponse(
        final Context context,
        final String applicationId,
        final boolean isAutoPublish) {
    try {
        if (context == null || applicationId == null) {
            throw new IllegalArgumentException("Both context and applicationId must be non-null");
        }
        AttributionIdentifiers identifiers = AttributionIdentifiers.getAttributionIdentifiers(context);
        SharedPreferences preferences = context.getSharedPreferences(ATTRIBUTION_PREFERENCES, Context.MODE_PRIVATE);
        String pingKey = applicationId+"ping";
        String jsonKey = applicationId+"json";
        long lastPing = preferences.getLong(pingKey, 0);
        String lastResponseJSON = preferences.getString(jsonKey, null);

        // prevent auto publish from occurring if we have an explicit call.
        if (!isAutoPublish) {
            setShouldAutoPublishInstall(false);
        }

        GraphObject publishParams = GraphObject.Factory.create();
        publishParams.setProperty(ANALYTICS_EVENT, MOBILE_INSTALL_EVENT);

        Utility.setAppEventAttributionParameters(publishParams,
                identifiers,
                Utility.getHashedDeviceAndAppID(context, applicationId),
                getLimitEventAndDataUsage(context));
        publishParams.setProperty(AUTO_PUBLISH, isAutoPublish);
        publishParams.setProperty("application_package_name", context.getPackageName());

        String publishUrl = String.format(PUBLISH_ACTIVITY_PATH, applicationId);
        Request publishRequest = Request.newPostRequest(null, publishUrl, publishParams, null);

        if (lastPing != 0) {
            GraphObject graphObject = null;
            try {
                if (lastResponseJSON != null) {
                    graphObject = GraphObject.Factory.create(new JSONObject(lastResponseJSON));
                }
            }
            catch (JSONException je) {
                // return the default graph object if there is any problem reading the data.
            }
            if (graphObject == null) {
                return Response.createResponsesFromString("true", null, new RequestBatch(publishRequest), true).get(0);
            } else {
                return new Response(null, null, null, graphObject, true);
            }
        } else if (identifiers == null ||
                   (identifiers.getAndroidAdvertiserId() == null && identifiers.getAttributionId() == null)) {
            throw new FacebookException("No attribution id available to send to server.");
        } else {
            if (!Utility.queryAppSettings(applicationId, false).supportsAttribution()) {
                throw new FacebookException("Install attribution has been disabled on the server.");
            }

            Response publishResponse = publishRequest.executeAndWait();

            // denote success since no error threw from the post.
            SharedPreferences.Editor editor = preferences.edit();
            lastPing = System.currentTimeMillis();
            editor.putLong(pingKey, lastPing);

            // if we got an object response back, cache the string of the JSON.
            if (publishResponse.getGraphObject() != null &&
                publishResponse.getGraphObject().getInnerJSONObject() != null) {
                editor.putString(jsonKey, publishResponse.getGraphObject().getInnerJSONObject().toString());
            }
            editor.apply();

            return publishResponse;
        }
    } catch (Exception e) {
        // if there was an error, fall through to the failure case.
        Utility.logd("Facebook-publish", e);
        return new Response(null, null, new FacebookRequestError(null, e));
    }
}
 
开发者ID:jacquesgiraudel,项目名称:TP-Formation-Android,代码行数:79,代码来源:Settings.java

示例4: publishInstallAndWaitForResponse

import com.facebook.internal.AttributionIdentifiers; //导入方法依赖的package包/类
static Response publishInstallAndWaitForResponse(
        final Context context,
        final String applicationId,
        final boolean isAutoPublish) {
    try {
        if (context == null || applicationId == null) {
            throw new IllegalArgumentException("Both context and applicationId must be non-null");
        }
        AttributionIdentifiers identifiers = AttributionIdentifiers.getAttributionIdentifiers(context);
        SharedPreferences preferences = context.getSharedPreferences(ATTRIBUTION_PREFERENCES, Context.MODE_PRIVATE);
        String pingKey = applicationId+"ping";
        String jsonKey = applicationId+"json";
        long lastPing = preferences.getLong(pingKey, 0);
        String lastResponseJSON = preferences.getString(jsonKey, null);

        // prevent auto publish from occurring if we have an explicit call.
        if (!isAutoPublish) {
            setShouldAutoPublishInstall(false);
        }

        GraphObject publishParams = GraphObject.Factory.create();
        publishParams.setProperty(ANALYTICS_EVENT, MOBILE_INSTALL_EVENT);

        Utility.setAppEventAttributionParameters(publishParams,
                identifiers,
                Utility.getHashedDeviceAndAppID(context, applicationId),
                getLimitEventAndDataUsage(context));
        publishParams.setProperty(AUTO_PUBLISH, isAutoPublish);
        publishParams.setProperty("application_package_name", context.getPackageName());

        String publishUrl = String.format(PUBLISH_ACTIVITY_PATH, applicationId);
        Request publishRequest = Request.newPostRequest(null, publishUrl, publishParams, null);

        if (lastPing != 0) {
            GraphObject graphObject = null;
            try {
                if (lastResponseJSON != null) {
                    graphObject = GraphObject.Factory.create(new JSONObject(lastResponseJSON));
                }
            }
            catch (JSONException je) {
                // return the default graph object if there is any problem reading the data.
            }
            if (graphObject == null) {
                return Response.createResponsesFromString("true", null, new RequestBatch(publishRequest), true).get(0);
            } else {
                return new Response(null, null, null, graphObject, true);
            }
        } else if (identifiers == null ||
                   (identifiers.getAndroidAdvertiserId() == null && identifiers.getAttributionId() == null)) {
            throw new FacebookException("No attribution id available to send to server.");
        } else {
            if (!Utility.queryAppSettings(applicationId, false).supportsAttribution()) {
                throw new FacebookException("Install attribution has been disabled on the server.");
            }

            Response publishResponse = publishRequest.executeAndWait();

            // denote success since no error threw from the post.
            SharedPreferences.Editor editor = preferences.edit();
            lastPing = System.currentTimeMillis();
            editor.putLong(pingKey, lastPing);

            // if we got an object response back, cache the string of the JSON.
            if (publishResponse.getGraphObject() != null &&
                publishResponse.getGraphObject().getInnerJSONObject() != null) {
                editor.putString(jsonKey, publishResponse.getGraphObject().getInnerJSONObject().toString());
            }
            editor.commit();

            return publishResponse;
        }
    } catch (Exception e) {
        // if there was an error, fall through to the failure case.
        Utility.logd("Facebook-publish", e);
        return new Response(null, null, new FacebookRequestError(null, e));
    }
}
 
开发者ID:bdentino,项目名称:Qtino.SharingKit,代码行数:79,代码来源:Settings.java

示例5: publishInstallAndWaitForResponse

import com.facebook.internal.AttributionIdentifiers; //导入方法依赖的package包/类
static Response publishInstallAndWaitForResponse(
        final Context context,
        final String applicationId,
        final boolean isAutoPublish) {
    try {
        if (context == null || applicationId == null) {
            throw new IllegalArgumentException("Both context and applicationId must be non-null");
        }
        AttributionIdentifiers identifiers = AttributionIdentifiers.getAttributionIdentifiers(context);
        SharedPreferences preferences = context.getSharedPreferences(ATTRIBUTION_PREFERENCES, Context.MODE_PRIVATE);
        String pingKey = applicationId+"ping";
        String jsonKey = applicationId+"json";
        long lastPing = preferences.getLong(pingKey, 0);
        String lastResponseJSON = preferences.getString(jsonKey, null);

        // prevent auto publish from occurring if we have an explicit call.
        if (!isAutoPublish) {
            setShouldAutoPublishInstall(false);
        }

        GraphObject publishParams = GraphObject.Factory.create();
        publishParams.setProperty(ANALYTICS_EVENT, MOBILE_INSTALL_EVENT);

        Utility.setAppEventAttributionParameters(publishParams,
                identifiers,
                Utility.getHashedDeviceAndAppID(context, applicationId),
                getLimitEventAndDataUsage(context));
        publishParams.setProperty(AUTO_PUBLISH, isAutoPublish);
        publishParams.setProperty("application_package_name", context.getPackageName());

        String publishUrl = String.format(PUBLISH_ACTIVITY_PATH, applicationId);
        Request publishRequest = Request.newPostRequest(null, publishUrl, publishParams, null);

        if (lastPing != 0) {
            GraphObject graphObject = null;
            try {
                if (lastResponseJSON != null) {
                    graphObject = GraphObject.Factory.create(new JSONObject(lastResponseJSON));
                }
            }
            catch (JSONException je) {
                // return the default graph object if there is any problem reading the data.
            }
            if (graphObject == null) {
                return Response.createResponsesFromString("true", null, new RequestBatch(publishRequest), true).get(0);
            } else {
                return new Response(null, null, graphObject, true);
            }
        } else if (identifiers.getAndroidAdvertiserId() == null && identifiers.getAttributionId() == null) {
            throw new FacebookException("No attribution id available to send to server.");
        } else {
            if (!Utility.queryAppSettings(applicationId, false).supportsAttribution()) {
                throw new FacebookException("Install attribution has been disabled on the server.");
            }

            Response publishResponse = publishRequest.executeAndWait();

            // denote success since no error threw from the post.
            SharedPreferences.Editor editor = preferences.edit();
            lastPing = System.currentTimeMillis();
            editor.putLong(pingKey, lastPing);

            // if we got an object response back, cache the string of the JSON.
            if (publishResponse.getGraphObject() != null &&
                publishResponse.getGraphObject().getInnerJSONObject() != null) {
                editor.putString(jsonKey, publishResponse.getGraphObject().getInnerJSONObject().toString());
            }
            editor.commit();

            return publishResponse;
        }
    } catch (Exception e) {
        // if there was an error, fall through to the failure case.
        Utility.logd("Facebook-publish", e);
        return new Response(null, null, new FacebookRequestError(null, e));
    }
}
 
开发者ID:hoyin258,项目名称:MisterWok,代码行数:78,代码来源:Settings.java


注:本文中的com.facebook.internal.AttributionIdentifiers.getAndroidAdvertiserId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。