Java Code Examples for com.facebook.internal.Utility#logd()
The following examples show how to use
com.facebook.internal.Utility#logd() .
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: AppEventsLogger.java From kognitivo with Apache License 2.0 | 5 votes |
private static void flushAndWait(final FlushReason reason) { Set<AccessTokenAppIdPair> keysToFlush; synchronized (staticLock) { if (requestInFlight) { return; } requestInFlight = true; keysToFlush = new HashSet<AccessTokenAppIdPair>(stateMap.keySet()); } accumulatePersistedEvents(); FlushStatistics flushResults = null; try { flushResults = buildAndExecuteRequests(reason, keysToFlush); } catch (Exception e) { Utility.logd(TAG, "Caught unexpected exception while flushing: ", e); } synchronized (staticLock) { requestInFlight = false; } if (flushResults != null) { final Intent intent = new Intent(ACTION_APP_EVENTS_FLUSHED); intent.putExtra(APP_EVENTS_EXTRA_NUM_EVENTS_FLUSHED, flushResults.numEvents); intent.putExtra(APP_EVENTS_EXTRA_FLUSH_RESULT, flushResults.result); LocalBroadcastManager.getInstance(applicationContext).sendBroadcast(intent); } }
Example 2
Source File: Session.java From HypFacebook with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected Void doInBackground(Void... voids) { try { Settings.publishInstallAndWait(mApplicationContext, mApplicationId); } catch (Exception e) { Utility.logd("Facebook-publish", e); } return null; }
Example 3
Source File: AuthorizationClient.java From facebook-api-android-maven with Apache License 2.0 | 5 votes |
private void saveCookieToken(String token) { Context context = getStartActivityDelegate().getActivityContext(); SharedPreferences sharedPreferences = context.getSharedPreferences( WEB_VIEW_AUTH_HANDLER_STORE, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString(WEB_VIEW_AUTH_HANDLER_TOKEN_KEY, token); if (!editor.commit()) { Utility.logd(TAG, "Could not update saved web view auth handler token."); } }
Example 4
Source File: AuthorizationClient.java From FacebookNewsfeedSample-Android with Apache License 2.0 | 5 votes |
private void saveCookieToken(String token) { Context context = getStartActivityDelegate().getActivityContext(); SharedPreferences sharedPreferences = context.getSharedPreferences( WEB_VIEW_AUTH_HANDLER_STORE, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString(WEB_VIEW_AUTH_HANDLER_TOKEN_KEY, token); if (!editor.commit()) { Utility.logd(TAG, "Could not update saved web view auth handler token."); } }
Example 5
Source File: AuthorizationClient.java From barterli_android with Apache License 2.0 | 5 votes |
private void saveCookieToken(String token) { Context context = getStartActivityDelegate().getActivityContext(); SharedPreferences sharedPreferences = context.getSharedPreferences( WEB_VIEW_AUTH_HANDLER_STORE, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString(WEB_VIEW_AUTH_HANDLER_TOKEN_KEY, token); if (!editor.commit()) { Utility.logd(TAG, "Could not update saved web view auth handler token."); } }
Example 6
Source File: Session.java From aws-mobile-self-paced-labs-samples with Apache License 2.0 | 5 votes |
@Override protected Void doInBackground(Void... voids) { try { Settings.publishInstallAndWait(mApplicationContext, mApplicationId); } catch (Exception e) { Utility.logd("Facebook-publish", e); } return null; }
Example 7
Source File: WebDialog.java From KlyphMessenger with MIT License | 5 votes |
@Override public void onPageStarted(WebView view, String url, Bitmap favicon) { Utility.logd(LOG_TAG, "Webview loading URL: " + url); super.onPageStarted(view, url, favicon); if (!isDetached) { spinner.show(); } }
Example 8
Source File: WebDialog.java From aws-mobile-self-paced-labs-samples with Apache License 2.0 | 5 votes |
@Override public void onPageStarted(WebView view, String url, Bitmap favicon) { Utility.logd(LOG_TAG, "Webview loading URL: " + url); super.onPageStarted(view, url, favicon); if (!isDetached) { spinner.show(); } }
Example 9
Source File: AuthorizationClient.java From Klyph with MIT License | 5 votes |
private void saveCookieToken(String token) { Context context = getStartActivityDelegate().getActivityContext(); SharedPreferences sharedPreferences = context.getSharedPreferences( WEB_VIEW_AUTH_HANDLER_STORE, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString(WEB_VIEW_AUTH_HANDLER_TOKEN_KEY, token); if (!editor.commit()) { Utility.logd(TAG, "Could not update saved web view auth handler token."); } }
Example 10
Source File: Session.java From facebook-api-android-maven with Apache License 2.0 | 5 votes |
@Override protected Void doInBackground(Void... voids) { try { Settings.publishInstallAndWaitForResponse(mApplicationContext, mApplicationId, true); } catch (Exception e) { Utility.logd("Facebook-publish", e); } return null; }
Example 11
Source File: WebDialog.java From platform-friends-android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void onPageStarted(WebView view, String url, Bitmap favicon) { Utility.logd(LOG_TAG, "Webview loading URL: " + url); super.onPageStarted(view, url, favicon); if (!isDetached) { spinner.show(); } }
Example 12
Source File: AuthorizationClient.java From platform-friends-android with BSD 2-Clause "Simplified" License | 5 votes |
private void saveCookieToken(String token) { Context context = getStartActivityDelegate().getActivityContext(); SharedPreferences sharedPreferences = context.getSharedPreferences( WEB_VIEW_AUTH_HANDLER_STORE, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString(WEB_VIEW_AUTH_HANDLER_TOKEN_KEY, token); if (!editor.commit()) { Utility.logd(TAG, "Could not update saved web view auth handler token."); } }
Example 13
Source File: AppEventsLogger.java From kognitivo with Apache License 2.0 | 5 votes |
private byte[] getStringAsByteArray(String jsonString) { byte[] jsonUtf8 = null; try { jsonUtf8 = jsonString.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { // shouldn't happen, but just in case: Utility.logd("Encoding exception: ", e); } return jsonUtf8; }
Example 14
Source File: Session.java From KlyphMessenger with MIT License | 5 votes |
@Override protected Void doInBackground(Void... voids) { try { Settings.publishInstallAndWaitForResponse(mApplicationContext, mApplicationId, true); } catch (Exception e) { Utility.logd("Facebook-publish", e); } return null; }
Example 15
Source File: WebDialog.java From facebook-api-android-maven with Apache License 2.0 | 4 votes |
@Override @SuppressWarnings("deprecation") public boolean shouldOverrideUrlLoading(WebView view, String url) { Utility.logd(LOG_TAG, "Redirect URL: " + url); if (url.startsWith(WebDialog.REDIRECT_URI)) { Bundle values = Util.parseUrl(url); String error = values.getString("error"); if (error == null) { error = values.getString("error_type"); } String errorMessage = values.getString("error_msg"); if (errorMessage == null) { errorMessage = values.getString("error_description"); } String errorCodeString = values.getString("error_code"); int errorCode = FacebookRequestError.INVALID_ERROR_CODE; if (!Utility.isNullOrEmpty(errorCodeString)) { try { errorCode = Integer.parseInt(errorCodeString); } catch (NumberFormatException ex) { errorCode = FacebookRequestError.INVALID_ERROR_CODE; } } if (Utility.isNullOrEmpty(error) && Utility .isNullOrEmpty(errorMessage) && errorCode == FacebookRequestError.INVALID_ERROR_CODE) { sendSuccessToListener(values); } else if (error != null && (error.equals("access_denied") || error.equals("OAuthAccessDeniedException"))) { sendCancelToListener(); } else { FacebookRequestError requestError = new FacebookRequestError(errorCode, error, errorMessage); sendErrorToListener(new FacebookServiceException(requestError, errorMessage)); } WebDialog.this.dismiss(); return true; } else if (url.startsWith(WebDialog.CANCEL_URI)) { sendCancelToListener(); WebDialog.this.dismiss(); return true; } else if (url.contains(DISPLAY_TOUCH)) { return false; } // launch non-dialog URLs in a full browser getContext().startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse(url))); return true; }
Example 16
Source File: Settings.java From FacebookImageShareIntent with MIT License | 4 votes |
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)); } }
Example 17
Source File: WebDialog.java From KlyphMessenger with MIT License | 4 votes |
@Override @SuppressWarnings("deprecation") public boolean shouldOverrideUrlLoading(WebView view, String url) { Utility.logd(LOG_TAG, "Redirect URL: " + url); if (url.startsWith(WebDialog.REDIRECT_URI)) { Bundle values = Util.parseUrl(url); String error = values.getString("error"); if (error == null) { error = values.getString("error_type"); } String errorMessage = values.getString("error_msg"); if (errorMessage == null) { errorMessage = values.getString("error_description"); } String errorCodeString = values.getString("error_code"); int errorCode = FacebookRequestError.INVALID_ERROR_CODE; if (!Utility.isNullOrEmpty(errorCodeString)) { try { errorCode = Integer.parseInt(errorCodeString); } catch (NumberFormatException ex) { errorCode = FacebookRequestError.INVALID_ERROR_CODE; } } if (Utility.isNullOrEmpty(error) && Utility .isNullOrEmpty(errorMessage) && errorCode == FacebookRequestError.INVALID_ERROR_CODE) { sendSuccessToListener(values); } else if (error != null && (error.equals("access_denied") || error.equals("OAuthAccessDeniedException"))) { sendCancelToListener(); } else { FacebookRequestError requestError = new FacebookRequestError(errorCode, error, errorMessage); sendErrorToListener(new FacebookServiceException(requestError, errorMessage)); } WebDialog.this.dismiss(); return true; } else if (url.startsWith(WebDialog.CANCEL_URI)) { sendCancelToListener(); WebDialog.this.dismiss(); return true; } else if (url.contains(DISPLAY_TOUCH)) { return false; } // launch non-dialog URLs in a full browser getContext().startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse(url))); return true; }
Example 18
Source File: Settings.java From FacebookNewsfeedSample-Android with Apache License 2.0 | 4 votes |
/** * Manually publish install attribution to the Facebook graph. Internally handles caching repeat calls to prevent * multiple installs being published to the graph. * @param context the current Context * @param applicationId the fb application being published. * @return returns a Response object, carrying the server response, or an error. */ public static Response publishInstallAndWaitForResponse(final Context context, final String applicationId) { try { if (context == null || applicationId == null) { throw new IllegalArgumentException("Both context and applicationId must be non-null"); } String attributionId = Settings.getAttributionId(context.getContentResolver()); 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); GraphObject publishParams = GraphObject.Factory.create(); publishParams.setProperty(ANALYTICS_EVENT, MOBILE_INSTALL_EVENT); publishParams.setProperty(ATTRIBUTION_KEY, attributionId); 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 (attributionId == null) { throw new FacebookException("No attribution id returned from the Facebook application"); } else { if (!Utility.queryAppAttributionSupportAndWait(applicationId)) { 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)); } }
Example 19
Source File: Settings.java From facebook-api-android-maven with Apache License 2.0 | 4 votes |
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)); } }
Example 20
Source File: Settings.java From android-skeleton-project with MIT License | 4 votes |
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)); } }