facebook - Android AccessToken.getCurrentAccessToken() always null in another activity -
i'm trying implement activity shows facebook friend's of user.
graphrequest request = graphrequest.newmerequest(accesstoken.getcurrentaccesstoken(), new graphrequest.graphjsonobjectcallback() { @override public void oncompleted(jsonobject object, graphresponse response) { if (response.geterror() != null) log.d("xxx", "facebook graph request error"); else log.d("xxx", "facebook graph request success"); } }); bundle parameters = new bundle(); parameters.putstring("fields", "friends"); request.setparameters(parameters); request.executeasync();
but currentaccesstoken null. if user logged in 10 seconds before.
this login code :
parsefacebookutils.loginwithreadpermissionsinbackground(this, arrays.aslist("public_profile", "user_birthday", "user_friends", "user_photos", "email"), new logincallback() { @override public void done(parseuser user, parseexception err) { if (user == null) { log.d("xxx", "uh oh. user cancelled facebook login."); } else if (user.isnew()) { log.d("xxx", "user signed , logged in through facebook!"); makemerequest(); } else { log.d("xxx", "user logged in through facebook!"); makemerequest(); } } }); private void makemerequest(){ graphrequest request = graphrequest.newmerequest(accesstoken.getcurrentaccesstoken(), new graphrequest.graphjsonobjectcallback() { @override public void oncompleted(jsonobject json, graphresponse response) { if (response.geterror() != null) { log.d("xxx", "facebook graph request error"); } else { log.d("xxx", "facebook graph request success"); ... } } }); bundle parameters = new bundle(); parameters.putstring("fields", "id,name,picture.type(large),email,birthday,first_name,last_name,gender,locale"); request.setparameters(parameters); request.executeasync(); }
i'm pretty sure ahve forgotten can't figure out ..
thanks,
Comments
Post a Comment