Я использую FB SDK версии 4.5.1 с eclipse для входа в Facebook. Иногда он успешно регистрируется, но иногда он дает мне это сообщение об ошибке «CONNECTION FAILURE». Это проблема с подключением к Интернету или кодом?FB SDK (4.5.1) login: Connection Failed
Вот мой код:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
Log.d(TAG,"Fb initialzed");
callbackManager = CallbackManager.Factory.create();
//LoginButton loginButton= (LoginButton)findViewById(R.id.fb_login_button);
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult result) {
// TODO Auto-generated method stub
Log.d(TAG,"Login success");
Intent I = new Intent(getApplicationContext(), Games.class);
startActivity(I);
}
private void showAlert() {
new AlertDialog.Builder(GameSurvey.this)
.setTitle(R.string.cancelled)
.setMessage(R.string.permission_not_granted)
.setPositiveButton(R.string.ok, null)
.show();
}
@Override
public void onCancel() {
// TODO Auto-generated method stub
Log.d(TAG,"Login cancelled");
}
@Override
public void onError(FacebookException error) {
// TODO Auto-generated method stub
if(error instanceof FacebookAuthorizationException)
Log.d(TAG,error.toString());
showAlert();
}
});
Log.d(TAG, "here");
setContentView(R.layout.activity_game_survey);
profileTracker = new ProfileTracker() {
@Override
protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
updateUI();
// It's possible that we were waiting for Profile to be populated in order to
// post a status update.
}
};
profilePictureView = (ProfilePictureView) findViewById(R.id.profilePicture);
}
Вы получаете это в обратном вызове 'onError'? если это так, то это, скорее всего, проблема связи. – ifaour
@ifaour yes, Можете ли вы оставить свой комментарий в качестве ответа, чтобы я мог его принять. – Alaa