Monday, December 29, 2014

Facebook Android Sdk : Serialize GraphUser object

If you check at the Facebook sdk GraphUser object documentation , it does not implements the as a result of which you can pass the GraphUser object through activities.

Though if you like to pass GraphUser to other activities, you can do it by saving GraphUser json string in a String instance and then pass it,

// Save GraphUser json information in String instance and pass to another activity using intent
List<GraphUser> selectedUsers = friendPickerFragment.getSelection();
List<GraphUser> selectedUsersJson = new ArrayList<String>();
for (GraphUser graphUser : selectedUsers) {

// Re-initialize the GraphUser from the saved graph user json from the intent
List<GraphUser> selectedUsers = new ArrayList<GraphUser>();
for (String graphUserJson : selectedUsersJson) {
selectedUsers .add(GraphObject.Factory.create(new JSONObject(graphUserJson),GraphUser.class));

Happy Serializing :)

No comments:

AWS Certified Solutions Architect Associate - AWS Introduction - Questions

All the Best !!! Show Result !! Try Again !! ×