Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mark selected user as checked in FriendPicker (Facebook SDK for Android)

I've done the tutorials for the Facebook SDK for Android (Especially the "Show Friends"-tutorial).

How can I mark the selected users which i've selected before at the PickerActivity when i click on the "Show Friends"-button again?

like image 242
mbecker Avatar asked Jan 26 '13 21:01

mbecker


2 Answers

I've looked at Facebook SDK's source code and it seems to me that PickerFragment does not give you possibility to reselect previously selected items. Since Facebook SDK is published under Apache License 2.0 and you have access to full source code I guess you could try to modify PickerFragment in such a way that it will have necessary methods.

like image 115
Damian Jeżewski Avatar answered Oct 02 '22 08:10

Damian Jeżewski


You have to pass comma separated string with selected facebook user ids in the bundle to the FriendPickerFragment.

Bundle args = new Bundle();
args.putString("com.facebook.android.PickerFragment.Selection", "11111, 2222, 333, already selected facebook ids....");
friendPickerFragment = new FriendPickerFragment(args);

In PickerFragment's onActivityCreated() it will parse the selected ids shows as selected in list. You can see the following code in PickerFragment in FacebookSDK.

selectionStrategy.readSelectionFromBundle(savedInstanceState, SELECTION_BUNDLE_KEY);
like image 25
Santhosh Avatar answered Oct 02 '22 10:10

Santhosh