I'm developing an android native app using Facebook SDK 3.5.
I'm trying to have an autocompletetextview where I can pick some facebook friends, for this I'm using an newMyFriendsRequest as below:
private void fbFriendsRequest(final Session session) {
Request request = Request.newMyFriendsRequest(session, new Request.GraphUserListCallback() {
@Override
public void onCompleted(List<GraphUser> listFacebookFriends, Response response) {
// If the response is successful
if (session == Session.getActiveSession()) {
if (listFacebookFriends != null) {
mAdapter = new GraphUserAdapter(FriendPicker.this, listFacebookFriends);
mAutoComplete.setAdapter(mAdapter);
Toast.makeText(FriendPicker.this,"Friends Loaded",Toast.LENGTH_SHORT).show();
}
}
if (response.getError() != null) {
// Handle errors, will do so later.
}
}
});
request.executeAsync();
}
Then each time the user pick a row from the autocompletetextview I add this row to another list, and when a I press OK button I have:
public void onOkClick(View v) {
if(mGraphUsersList.size()==0) {
setResult(RESULT_CANCELED,null);
} else {
Intent returnIntent = new Intent();
Iterator<GraphUser> itr = mGraphUsersList.iterator();
int n = mGraphUsersList.size();
String[] idfb = new String[n];
String[] names = new String[n];
String[] lastnames = new String[n];
int i = 0;
while(itr.hasNext()) {
GraphUser User = (GraphUser) itr.next();
idfb[i]=User.getId();
names[i]=User.getFirstName(); // problem
lastnames[i]=User.getLastName(); // problem
i++;
}
returnIntent.putExtra("idfb",idfb);
returnIntent.putExtra("names",names);
returnIntent.putExtra("lastnames",lastnames);
setResult(RESULT_OK,returnIntent);
}
finish();
}
When I use the getFirstName() and getLastName() functions I have null strings, but if I use getName() function it's return the name+lastname. It's like if in the list given by newMyFriendsRequest something has been lost.
Anyone knows a workaround for this?
Bundle bundle = new Bundle(); bundle.putString("fields", "id,first_name,last_name"); request.setParameters(bundle);
– Modality