/**
   * This function does the heavy lifting of publishing an install.
   *
   * @param fb
   * @param applicationId
   * @param context
   * @throws Exception
   */
  private static void publishInstall(
      final Facebook fb, final String applicationId, final Context context)
      throws JSONException, FacebookError, MalformedURLException, IOException {

    String attributionId = Facebook.getAttributionId(context.getContentResolver());
    SharedPreferences preferences =
        context.getSharedPreferences(ATTRIBUTION_PREFERENCES, Context.MODE_PRIVATE);
    String pingKey = applicationId + "ping";
    long lastPing = preferences.getLong(pingKey, 0);
    if (lastPing == 0 && attributionId != null) {
      Bundle supportsAttributionParams = new Bundle();
      supportsAttributionParams.putString(APPLICATION_FIELDS, SUPPORTS_ATTRIBUTION);
      JSONObject supportResponse =
          Util.parseJson(fb.request(applicationId, supportsAttributionParams));
      Object doesSupportAttribution = (Boolean) supportResponse.get(SUPPORTS_ATTRIBUTION);

      if (!(doesSupportAttribution instanceof Boolean)) {
        throw new JSONException(
            String.format(
                "%s contains %s instead of a Boolean",
                SUPPORTS_ATTRIBUTION, doesSupportAttribution));
      }

      if ((Boolean) doesSupportAttribution) {
        Bundle publishParams = new Bundle();
        publishParams.putString(ANALYTICS_EVENT, MOBILE_INSTALL_EVENT);
        publishParams.putString(ATTRIBUTION_KEY, attributionId);

        String publishUrl = String.format(PUBLISH_ACTIVITY_PATH, applicationId);

        fb.request(publishUrl, publishParams, "POST");

        // denote success since no error threw from the post.
        SharedPreferences.Editor editor = preferences.edit();
        editor.putLong(pingKey, System.currentTimeMillis());
        editor.commit();
      }
    }
  }
 /**
  * @param message the sharing message
  * @param photo the photo to share
  * @param thumbSize the thumb image size
  * @param appendToken whether to append share token to the photo url
  * @throws FileNotFoundException
  * @throws MalformedURLException
  * @throws IOException
  */
 public static void sharePhoto(
     String message, Photo photo, ReturnSizes thumbSize, boolean appendToken)
     throws FileNotFoundException, MalformedURLException, IOException {
   Facebook facebook = FacebookProvider.getFacebook();
   Bundle bparams = new Bundle();
   bparams.putString("message", message);
   bparams.putString("name", photo.getTitle());
   bparams.putString("caption", photo.getTitle());
   bparams.putString(
       "description", CommonUtils.getStringResource(R.string.share_facebook_default_description));
   bparams.putString("picture", photo.getUrl(thumbSize.toString()));
   bparams.putString("link", PhotoUtils.getShareUrl(photo, appendToken));
   TrackerUtils.trackSocial("facebook", "feed", message + " | " + photo.getUrl(Photo.URL));
   facebook.request("feed", bparams, "POST");
 }
    @Override
    protected Boolean doInBackground(Void... params) {
      try {
        Facebook facebook = FacebookProvider.getFacebook();
        Bundle bparams = new Bundle();
        bparams.putString("fields", "name");
        String response = facebook.request("me", bparams);
        JSONObject jsonObject = new JSONObject(response);

        name = jsonObject.getString("name");
        return true;
      } catch (Exception ex) {
        GuiUtils.error(TAG, R.string.errorCouldNotRetrieveFacebookScreenName, ex, activity);
      }
      return false;
    }