我的应用程序中有一个奇怪的问题,我已经实现了 facebook 的库,并记录了用户。我创建了哈希,我创建了 API 密钥(来自 facebook)等等一切都运行良好,只是我将类移动到另一个项目中,复制了布局的清单,并且我不再登录,如果你已经安装了 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);
}
对不起我的英语不好