Facebookのライブラリを実装したアプリに奇妙な問題があり、ユーザーをログに記録しています。ハッシュを作成し、(facebook から) API キーを作成したなど、すべてが完全に機能しましたが、クラスを別のプロジェクトに移動し、レイアウトとマニフェストの両方をコピーしただけで、facebook アプリをインストールした場合はログインしなくなりました(インストールされていれば動作します) ... 何を忘れたのでしょうか? ログインコードはこちら
// start Facebook Login
Session.openActiveSession(this, true, new Session.StatusCallback() {
// callback when session changes state
@Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
// make request to the /me API
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
// callback after Graph API response with user object
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
String nickname = user.getName();
String id = user.getId();
// TextView welcome = (TextView) findViewById(R.id.textView1);
// welcome.setText("Hello " + user.getName() + "!");
SharedPreferences prefs = getSharedPreferences("Preferenze", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
if (nickname != null) {
editor.putString("utente", ""+nickname);
editor.commit();
}
String fotoProfilo = "https://graph.facebook.com/" + id + "/picture";
if (id != null){
editor.putString("path", ""+fotoProfilo);
editor.commit();
}
Intent LogIn= new Intent(getBaseContext(), MenuLoggato.class);
LogIn.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
LogIn.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
LogIn.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(LogIn);
finish();
//fin qui ci arriva
}
}
});
} else {
System.out.println("non è entrato");
}
System.out.println("Log in non riuscito");
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
私の英語でごめんなさい