我在登录 facebook 时使用的是 facebook SDK 3.0,它返回登录屏幕而不是进入下一个活动,但我想直接进入下一个活动。
这是我的代码:-
if (session.isOpened()) {
token = session.getAccessToken();
Log.i("TAG", "Access Token" + token);
Request.executeMeRequestAsync(session,new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
id = user.getId();
Log.i("TAG", "User ID " + user.getId());
Log.i("TAG", "Email "+ user.asMap().get("email"));
try {
URL image_value = new URL("http://graph.facebook.com/"+id+"/picture?type=large" );
profPict=BitmapFactory.decodeStream(image_value.openConnection().getInputStream());
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//http://graph.facebook.com/4/picture
Intent i = new Intent(MainActivity.this,Next.class);
i.putExtra("BitmapImage", profPict);
startActivity(i);
// lblEmail.setText(user.asMap().get("email").toString());
}
}
});
}
和onActivityResult()
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode,
resultCode, data);}