Facebook Graph object not returning the values in android -
i want display users details in app facebook, here code:
private string builduserinfodisplay(graphuser user) { stringbuilder userinfo = new stringbuilder(""); userinfo.append(string.format("name: %s\n\n", user.getname())); userinfo.append(string.format("birthday: %s\n\n", user.getbirthday())); userinfo.append(string.format("location: %s\n\n", user.getlocation().getproperty("name"))); userinfo.append(string.format("locale: %s\n\n", user.getproperty("locale"))); //jsonarray languages = (jsonarray)user.getproperty("languages"); graphobjectlist<mygraphlanguage> languages = (user.cast(mygraphuser.class)).getlanguages(); if (languages.size() > 0) { arraylist<string> languagenames = new arraylist<string> (); (mygraphlanguage language : languages) { languagenames.add(language.getname()); } userinfo.append(string.format("languages: %s\n\n", languagenames.tostring())); } return userinfo.tostring(); } private void onsessionstatechange(session session, sessionstate state,exception exception) { if (state.isopened()) { userinfotextview.setvisibility(view.visible); settings.addloggingbehavior(loggingbehavior.requests); request.newmerequest(session, new request.graphusercallback(){ @override public void oncompleted(graphuser user, response response) { // todo auto-generated method stub if (user != null) { // display parsed user info userinfotextview.settext(builduserinfodisplay(user)); } }}).executeasync(); log.i(tag, "logged in..."); } else if (state.isclosed()) { userinfotextview.setvisibility(view.invisible); log.i(tag, "logged out..."); } }
thanks in advance..
add below code after declare , initial facebook loginbutton,
your_facebook_loginbutton.setreadpermissions(arrays.aslist("user_location", "user_birthday", "user_likes"));
otherwise, check had add languages information in profile. if user doesn't have data, must null. can see languages information in fb 'about' page -> contact , basic info
hope can you! reference: https://developers.facebook.com/docs/android/graph#userdata
Comments
Post a Comment