Facebook Photo Picker for Android
On a recent project, we needed a widget that would allow users to select a photo from their Facebook albums. “Surely the new Facebook Android SDK must support this.” I thought. Alas, my hopes were unfulfilled. “Well, I bet there is a third-party solution for this!”, I surmised, but again, my search was for naught. At this point I decided to roll up my sleeves and do it myself.
The Facebook SDK does not readily support access to photos, which seems like a common use case for which they would expose a dedicated set of API calls. Instead, one needs to make specific Facebook Graph calls using the SDK’s Request class. One thing to pay attention to is the packaging of parameters to pass to the Request constructor. Not you use an android.os.Bundle to package the parameters, and the structure can be derived from the Facebook Graph API Explorer.
I’ve created an Android Library project so you can use this on your next project that needs access to Facebook photos. you can find it on Github here:
https://github.com/GrioSF/AndroidFBPhotoPicker.git
Note you’ll need to create your own Facebook App to support the FBPhotoPickerTestApp. You can find a nice getting started tutorial for the Facebook Android SDK here:
https://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/
Feel free to fork and modify at will. If you have any suggestions for improvement, please leave a comment and I’ll get on it when I have a chance.
Here are some screenshots to give you an idea of what the UI looks like:
5 Comments