Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Facebook SDK with android.app.Fragment

I'm trying to follow the samples of Facebook SDK from developers.facebook.com site. However, what I know is it's Facebook SDK is working with Activity and android.support.v4.app.Fragment only.

Now in my application I'm using android.app.Fragment with all Fragments in my project and I don't really care about support to older version of Android.

Question is (in case I really need to use Facebook SDK with Fragment (means I don't use it with Activity)

  • How can I use it with android.app.Fragment?

if there's no possible way for first question

  • How can I make android.support.v4.app.Fragment works with other android.app.Fragment?

Thank you

like image 863
vfongmala Avatar asked Oct 17 '13 08:10

vfongmala


1 Answers

First, the second question - you can't. The support library is a complete reimplementation and not just a thin wrapper.

As for the Facebook SDK, you have two options.

1) Convert the Facebook SDK to use app.Fragment by changing all relevant import statements. This is allowed by the license and should mostly work but now you're maintaining a fork and that's not good.

2) Convert in a similar way your own code; you won't be able to get away with just imports but it's not a hard conversion... Whether you need the backwards support is irrelevant, you're already maintaining your app, so it doesn't add to your longterm technical debt.

like image 174
Delyan Avatar answered Jan 03 '23 14:01

Delyan