/** {@inheritDoc} */
  public void reloadUserInfo() {
    clearUserInfo();
    if (!isUserSignedIn()) {
      return;
    }

    final Bundle parameters = new Bundle();
    parameters.putString("fields", "name,picture.type(large)");
    final GraphRequest graphRequest = new GraphRequest(AccessToken.getCurrentAccessToken(), "me");
    graphRequest.setParameters(parameters);
    GraphResponse response = graphRequest.executeAndWait();

    JSONObject json = response.getJSONObject();
    try {
      userName = json.getString("name");
      userImageUrl = json.getJSONObject("picture").getJSONObject("data").getString("url");

    } catch (final JSONException jsonException) {
      Log.e(
          LOG_TAG,
          "Unable to get Facebook user info. " + jsonException.getMessage() + "\n" + response,
          jsonException);
      // Nothing much we can do here.
    }
  }
Exemplo n.º 2
0
    public final void onCompleted(GraphResponse graphresponse)
    {
        int i;
        if (graphresponse.getError() != null)
        {
            return;
        }
        graphresponse = graphresponse.getJSONObject();
        JSONObject jsonobject;
        try
        {
            graphresponse = graphresponse.getJSONArray("data");
        }
        // Misplaced declaration of an exception variable
        catch (GraphResponse graphresponse)
        {
            d.a(FacebookUtils.access$700(), "getPermissions", graphresponse);
            return;
        }
        i = 0;
_L2:
        if (i >= graphresponse.length())
        {
            break MISSING_BLOCK_LABEL_114;
        }
        jsonobject = graphresponse.getJSONObject(i);
        if ("granted".equals(jsonobject.getString("status")))
        {
            a.add(jsonobject.getString("permission"));
            break MISSING_BLOCK_LABEL_164;
        }
        if ("declined".equals(jsonobject.getString("status")))
        {
            b.add(jsonobject.getString("permission"));
        }
        break MISSING_BLOCK_LABEL_164;
        AccessToken.setCurrentAccessToken(new AccessToken(c.getToken(), FacebookSdk.getApplicationId(), FacebookUtils.access$300().a, a, b, AccessTokenSource.FACEBOOK_APPLICATION_WEB, c.getExpires(), null));
        FacebookUtils.setConnectionState(true);
        return;
        i++;
        if (true) goto _L2; else goto _L1
Exemplo n.º 3
0
  public static JSONObject awaitGetGraphMeRequestWithCache(final String accessToken) {
    JSONObject cachedValue = ProfileInformationCache.getProfileInformation(accessToken);
    if (cachedValue != null) {
      return cachedValue;
    }

    GraphRequest graphRequest = getGraphMeRequestWithCache(accessToken);
    GraphResponse response = graphRequest.executeAndWait();
    if (response.getError() != null) {
      return null;
    }

    return response.getJSONObject();
  }
 @Override
 public void OnFbSignInComplete(GraphResponse graphResponse, String error) {
   progressBar.setVisibility(View.GONE);
   if (error == null) {
     try {
       JSONObject jsonObject = graphResponse.getJSONObject();
       fbName.setText(jsonObject.getString("name"));
       fbEmail.setText(jsonObject.getString("email"));
       String id = jsonObject.getString("id");
       String profileImg = "http://graph.facebook.com/" + id + "/picture?type=large";
     } catch (JSONException e) {
       e.printStackTrace();
     }
   }
 }
 protected void processSuccess(GraphResponse graphresponse)
 {
     unlikeToken = Utility.safeGetStringFromResponse(graphresponse.getJSONObject(), "id");
 }