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


    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.


    现在登录按钮有两个方法:setFragment(final android.app.Fragment fragment)和setFragment(final setFragment(final Fragment fragment)Fragment fragment)

    链接地址: http://www.djcxy.com/p/75026.html

    上一篇: 准备机器学习数据集的正确方法是什么?

    下一篇: 如何使用android.app.Fragment使用Facebook SDK