这似乎没有连接和更新Facebook API中的文本字段,任何人都可以看到问题。我不得不将Request.executeMeRequestAsyc更改为Request.newMeRequest,因为它已被弃用。任何帮助将不胜感激。
代码段
公共类MainActivity扩展了Activity {
public void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Session.openActiveSession(this, true, new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
// TODO Auto-generated method stub
if (session.isOpened()) {
//---make request to the /me api---
Request.newMeRequest(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
// TODO Auto-generated method stub
if(user != null){
TextView welcome = (TextView) findViewById(R.id.welcome);
welcome.setText("Hello " + user.getName() + "!");
}
}
});
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
答案 0 :(得分:0)
您需要明确地在请求上调用executeAsync:
if (session.isOpened()) {
//---make request to the /me api---
Request.newMeRequest(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
// TODO Auto-generated method stub
if(user != null){
TextView welcome = (TextView) findViewById(R.id.welcome);
welcome.setText("Hello " + user.getName() + "!");
}
}
}).executeAsync(); // <----- ADD THIS
}