profile.getProfile()在代碼下運行時返回null。
我正在使用正確的hashkey,正確的應用程序ID。
我在onDestory()方法中停止配置文件和訪問示蹤器
我沒有使用任何Facebook應用程序 任何想法來解決這個問題。配置文件在使用Facebook API時返回null
@Override
public void onCreate(Bundle savedInstane)
{
super.onCreate(savedInstane);
// Add code to print out the key hash
FacebookSdk.sdkInitialize(getActivity().getApplicationContext());
callbackManager = CallbackManager.Factory.create();
accessTokenTracker = new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(AccessToken accessToken, AccessToken accessToken1) {
}
};
profileTracker = new ProfileTracker() {
@Override
protected void onCurrentProfileChanged(Profile profile, Profile profile1) {
}
};
accessTokenTracker.startTracking();
profileTracker.startTracking();
}
private FacebookCallback<LoginResult> mcallBack = new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
AccessToken token = loginResult.getAccessToken();
Profile profile = Profile.getCurrentProfile();
Uri link = profile.getProfilePictureUri(20, 20);
Log.d("Message",link.toString());
display(profile);
}
};
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
void facebookLogin()
{
FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
setContentView(R.layout.activity_signin);
LoginButton login = (LoginButton)findViewById(R.id.login_button_facebook);
login.setReadPermissions(Arrays.asList("public_profile", "user_friends"));
login.registerCallback(callbackManager, mcallBackFacebook);
}
你給獲得Facebook的細節之前的權限工作正常? – MFP