本文整理汇总了Java中com.facebook.Profile.fetchProfileForCurrentAccessToken方法的典型用法代码示例。如果您正苦于以下问题:Java Profile.fetchProfileForCurrentAccessToken方法的具体用法?Java Profile.fetchProfileForCurrentAccessToken怎么用?Java Profile.fetchProfileForCurrentAccessToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.Profile
的用法示例。
在下文中一共展示了Profile.fetchProfileForCurrentAccessToken方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: finishLogin
import com.facebook.Profile; //导入方法依赖的package包/类
private void finishLogin(
AccessToken newToken,
LoginClient.Request origRequest,
FacebookException exception,
boolean isCanceled,
FacebookCallback<LoginResult> callback) {
if (newToken != null) {
AccessToken.setCurrentAccessToken(newToken);
Profile.fetchProfileForCurrentAccessToken();
}
if (callback != null) {
LoginResult loginResult = newToken != null
? computeLoginResult(origRequest, newToken)
: null;
// If there are no granted permissions, the operation is treated as cancel.
if (isCanceled
|| (loginResult != null
&& loginResult.getRecentlyGrantedPermissions().size() == 0)) {
callback.onCancel();
} else if (exception != null) {
callback.onError(exception);
} else if (newToken != null) {
callback.onSuccess(loginResult);
}
}
}
示例2: setFacebookDetails
import com.facebook.Profile; //导入方法依赖的package包/类
public static boolean setFacebookDetails() {
Profile.fetchProfileForCurrentAccessToken();
// try to get from Profile
if (Profile.getCurrentProfile() != null) {
username = Profile.getCurrentProfile().getFirstName();
picture = Profile.getCurrentProfile().getProfilePictureUri(200, 200);
} else {
//if Profile has not yet been updated, then
//manually send a request to Graph API to get the name
GraphRequest request = GraphRequest.newMeRequest(
AccessToken.getCurrentAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
username = object.optString("name");
picture = (Uri) object.opt("picture");
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,link,picture");
request.setParameters(parameters);
request.executeAsync();
}
return true;
}
示例3: finishLogin
import com.facebook.Profile; //导入方法依赖的package包/类
private void finishLogin(
AccessToken newToken,
FacebookException exception,
boolean isCanceled,
FacebookCallback<LoginResult> callback) {
if (newToken != null) {
AccessToken.setCurrentAccessToken(newToken);
Profile.fetchProfileForCurrentAccessToken();
}
if (callback != null) {
LoginResult loginResult = newToken != null
? computeLoginResult(pendingLoginRequest, newToken)
: null;
// If there are no granted permissions, the operation is treated as cancel.
if (isCanceled
|| (loginResult != null
&& loginResult.getRecentlyGrantedPermissions().size() == 0)) {
callback.onCancel();
return;
}
if (exception != null) {
callback.onError(exception);
} else if (newToken != null) {
callback.onSuccess(loginResult);
}
}
}