本文整理汇总了Java中com.facebook.Profile类的典型用法代码示例。如果您正苦于以下问题:Java Profile类的具体用法?Java Profile怎么用?Java Profile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Profile类属于com.facebook包,在下文中一共展示了Profile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSuccess
import com.facebook.Profile; //导入依赖的package包/类
@Override
public void onSuccess(com.facebook.login.LoginResult loginResult) {
Profile facebookProfile = Profile.getCurrentProfile();
if (facebookProfile == null) {
String errorMsg = InfoFromFacebookActivity.this.getResources().getString(R.string.facebook_error);
errorMsg = errorMsg + ".";
Snackbar.make(textViewFacebookName, errorMsg, Snackbar.LENGTH_LONG).show();
textViewFacebookName.setText(errorMsg);
} else {
facebookProfilePhoto.setProfileId(facebookProfile.getId());
textViewFacebookName.setText(facebookProfile.getName());
buttonAck.setEnabled(true);
buttonSwitch.setVisibility(Button.VISIBLE);
}
// TODO: Do not store access token - it is a security issue storing this
// TODO and appears to be of no benefit.
// AccessToken token = loginResult.getAccessToken();
// DataHolder data = DataHolder.getInstance(InfoFromFacebookActivity.this.getApplicationContext());
// data.setFacebookToken(token.getToken());
// data.persist();
}
示例2: initFBSdk
import com.facebook.Profile; //导入依赖的package包/类
private void initFBSdk() {
if (!FacebookSdk.isInitialized()) {
FacebookSdk.setApplicationId(ApiObjects.facebook.get("app_id"));
FacebookSdk.sdkInitialize(getActivity().getApplicationContext());
}
callbackManager = CallbackManager.Factory.create();
profileTracker = new ProfileTracker() {
@Override
protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
if (eventHandler != null) {
if (currentProfile != null)
eventHandler.onFacebookLoggedIn();
}
}
};
}
示例3: onCreate
import com.facebook.Profile; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getActivity().getApplicationContext());
callbackManager = CallbackManager.Factory.create();
accessTokenTracker = new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {
}
};
profileTracker = new ProfileTracker() {
@Override
protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
//Toast.makeText(getActivity(), "newProfile", Toast.LENGTH_SHORT).show();
//displayMessage(currentProfile);
}
};
accessTokenTracker.startTracking();
profileTracker.startTracking();
}
示例4: setFacebookRule
import com.facebook.Profile; //导入依赖的package包/类
private void setFacebookRule() {
callbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().registerCallback(callbackManager,
new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
EventBus.getDefault().post(MessageEvent.UPDATE_FACEBOOK_PROFILE);
}
@Override
public void onCancel() {
Log.d("Teste", "deu errp");
}
@Override
public void onError(FacebookException exception) {
Log.d("ErrorF", exception.toString());
}
}
);
Profile profile = Profile.getCurrentProfile();
if (profile != null) {
this.sidebar.showHideLogoff(true);
} else {
this.sidebar.showHideLogoff(false);
}
}
示例5: getImageStringFile
import com.facebook.Profile; //导入依赖的package包/类
private String getImageStringFile() {
try {
URL image = new URL(Profile.getCurrentProfile()
.getProfilePictureUri(140, 140).toString());
Resources res = getResources();
Bitmap src = BitmapFactory.decodeStream(image.openConnection().getInputStream());
ByteArrayOutputStream bYtE = new ByteArrayOutputStream();
src.compress(Bitmap.CompressFormat.PNG, 100, bYtE);
src.recycle();
byte[] byteArray = bYtE.toByteArray();
return Base64.encodeToString(byteArray, Base64.DEFAULT);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例6: addTemplateTasks
import com.facebook.Profile; //导入依赖的package包/类
private void addTemplateTasks() {
for (String task : NewEventActivity.TEMPLATE_TASKS[fromTemplateNumber]) {
JSONObject json = new JSONObject();
String eventId = String.valueOf(newEventId);
try {
json.put("name", task);
json.put("cost", 0);
} catch (JSONException e) {
e.printStackTrace();
}
ServerHandler.executePost(eventId, ServerHandler.EVENT_TASKS, Profile.getCurrentProfile().getId(), "", json, j -> {
if (j != null)
SplitAppLogger.writeLog(1, "Post new Task on event Creation (RESULT): " + j.toString());
});
}
}
示例7: updateUserData
import com.facebook.Profile; //导入依赖的package包/类
private void updateUserData(String email) {
Profile profile = Profile.getCurrentProfile();
mName.setText(profile.getName());
int photoDimention = getResources().getDimensionPixelSize(R.dimen.avatar_dimention);
Picasso.with(this)
.load(profile.getProfilePictureUri(photoDimention, photoDimention))
.transform(PicassoTransformations.getRoundedTransformation())
.error(R.drawable.ic_signup)
.placeholder(R.drawable.ic_signup)
.into(mPhotoProfile);
if (!TextUtils.isEmpty(email)) {
mEmail.setText(email);
}
}
示例8: startProfileTracking
import com.facebook.Profile; //导入依赖的package包/类
/**
* Start tracking profile.
*/
public void startProfileTracking() {
//Track profile
profileTracker = new ProfileTracker() {
@Override
protected void onCurrentProfileChanged(
Profile oldProfile,
Profile currentProfile) {
// App code comes here.
if (currentProfile != null && Config.IS_DEBUG_MODE)
Log.d(TAG, currentProfile.getName());
}
};
}
示例9: onCreate
import com.facebook.Profile; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getActivity().getApplicationContext());
mCallbackManager = CallbackManager.Factory.create();
profileTracker = new ProfileTracker() {
@Override
protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
final Profile profile = currentProfile;
if (profile != null) {
final Thread thread = new Thread() {
public void run() {
createUserFromFacebook(profile);
openListsOverview();
}
};
thread.start();
}
}
};
printKeyHash(getActivity());
}
示例10: updateUI
import com.facebook.Profile; //导入依赖的package包/类
private void updateUI() {
boolean loggedIn = AccessToken.getCurrentAccessToken() != null;
Profile profile = Profile.getCurrentProfile();
if (loggedIn && (profile != null)) {
profilePicture.setProfileId(profile.getId());
userName.setText(profile.getName());
name = profile.getName();
id = profile.getId();
// postLinkButton.setEnabled(true);
// postPictureButton.setEnabled(true);
} else {
profilePicture.setProfileId(null);
userName.setText(null);
// postLinkButton.setEnabled(false);
// postPictureButton.setEnabled(false);
}
}
示例11: ObtenerDatosFacebook
import com.facebook.Profile; //导入依赖的package包/类
/**
* Metodo para obtener el nombre de usuario y la fotografia de Facebook
*/
private void ObtenerDatosFacebook() {
//Para obtener datos del perfil tenemos que hacer un GraphRequest
GraphRequest request = GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(final JSONObject object, GraphResponse response) {
//Obtenemos los datos del perfil
Profile perfil = Profile.getCurrentProfile();
//Lo mostramos en pantalla y lo guardamos
foto.setProfileId(perfil.getId());
nombre.setText(object.optString("name"));
}
});
//Añadimos los parametros que hemos requerido y ejecutamos la peticion
Bundle parameters = new Bundle();
parameters.putString("fields", "name");
request.setParameters(parameters);
request.executeAsync();
}
示例12: setFacebookAvatar
import com.facebook.Profile; //导入依赖的package包/类
private void setFacebookAvatar() {
Profile fbProfile = Profile.getCurrentProfile();
String profileImageUri = fbProfile.getProfilePictureUri(250, 250).toString();
GetSocial.User.setAvatarUrl(profileImageUri, new CompletionCallback() {
@Override
public void onSuccess() {
_activityListener.invalidateUi();
}
@Override
public void onFailure(GetSocialException e) {
// failed to set avatar url
}
});
}
示例13: 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);
}
}
}
示例14: successLogin
import com.facebook.Profile; //导入依赖的package包/类
private void successLogin() {
loggedIn = true;
accessToken = AccessToken.getCurrentAccessToken();
profile = Profile.getCurrentProfile();
if (profile != null) { Utils.d("Name: " + profile.getName()); }
Utils.callScriptFunc("login", "true");
fetchUserInformationAndLogin();
}
示例15: dump
import com.facebook.Profile; //导入依赖的package包/类
public String dump() {
StringBuffer buf = new StringBuffer();
buf.append("FacebookSDK is initialized: " + FacebookSdk.isInitialized() + "\n");
buf.append("FacebookSDK app id: " + FacebookSdk.getApplicationId() + "\n");
buf.append("FacebookSDK app name: " + FacebookSdk.getApplicationName() + "\n");
buf.append("FacebookSDK app signature: " + FacebookSdk.getApplicationSignature(this) + "\n");
buf.append("FacebookSDK client token: " + FacebookSdk.getClientToken() + "\n");
buf.append("FacebookSDK facebook domain: " + FacebookSdk.getFacebookDomain() + "\n");
buf.append("FacebookSDK version: " + FacebookSdk.getSdkVersion() + "\n");
buf.append("FacebookSDK debug enabled: " + FacebookSdk.isDebugEnabled() + "\n");
Profile profile = Profile.getCurrentProfile();
if (profile == null) {
buf.append("Profile is null\n");
} else {
buf.append("Profile: First Name: " + profile.getFirstName() + "\n");
buf.append("Profile: Last Name: " + profile.getLastName() + "\n");
buf.append("Profile: Name: " + profile.getName() + "\n");
buf.append("Profile: Id: " + profile.getId() + "\n");
buf.append("Profile: LinkURI: " + profile.getLinkUri() + "\n");
buf.append("Profile: Pic URI: " + profile.getProfilePictureUri(100, 100) + "\n");
}
AccessToken currentToken = AccessToken.getCurrentAccessToken();
if (currentToken == null) {
buf.append("Current Access Token is null\n");
} else {
buf.append("CurToken: tok: " + currentToken.getToken() + "\n");
buf.append("CurToken: appid: " + currentToken.getApplicationId() + "\n");
buf.append("CurToken: expires: " + currentToken.getExpires().toString() + "\n");
}
return buf.toString();
}