在Android中登录Facebook SDK 3.0后如何直接进行下一步活动
作者:互联网
我登录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);}
解决方法:
嘿,请在onActivityResult块中插入以下代码:
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
if (Session.getActiveSession() != null || Session.getActiveSession().isOpened()){
Intent i = new Intent(MainActivity.this,Next.class);
startActivity(i);
}
这很好.
标签:facebook,facebook-android-sdk,android 来源: https://codeday.me/bug/20191123/2066883.html