我是 Facebook 与 Android 应用程序集成的新手。我正在尝试运行来自Facebook 的应用程序。但它不起作用。我没有得到用户名。为什么它不工作?谁能帮我。
我为会话变量得到了以下一个。
session: {Session state:OPENING, token:{AccessToken token:ACCESS_TOKEN_REMOVED permissions:[]}, appId:360610310722942}
session opened: false
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 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) {
final TextView welcome = (TextView) findViewById(R.id.welcome);
System.out.println("session: " + session);
System.out.println("session opened: " + session.isOpened());
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) {
welcome.setText("Hello "
+ user.getName() + "!");
}
}
});
}
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
System.out.println("onActivityResult");
Session.getActiveSession().onActivityResult(this, requestCode,
resultCode, data);
}