简体   繁体   English

如何将我的android SDK的标准片段与facebook SDK一起使用?

[英]how can I use the standard Fragment of the android SDK with facebook SDK?

I use facebook library compile 'com.facebook.android:facebook-android-sdk:4.4.0' 我使用facebook库compile 'com.facebook.android:facebook-android-sdk:4.4.0'

And I use method: 我使用方法:

LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("public_profile", "user_friends", "email"));

The problem is that before I passed this - Fragment from appcompat-v7:22.2.0' and everything worked But now i pass Fragment from android.app.Fragment and method logInWithReadPermissions does not accept it. 问题在于,在我通过this之前-来自appcompat-v7:22.2.0' Fragment一切正常,但现在我从android.app.Fragment传递Fragment,并且方法logInWithReadPermissions不接受它。

On the Facebook site i found: enter link description here 在我发现的Facebook网站上: 在此处输入链接描述

but no one says how can I use the standard Fragment of the android SDK with facebook 但是没有人说我如何在Facebook上使用android SDK的标准片段

That's because the Facebook SDK's LoginManager expects a android.support.v4.app.Fragment instead. 这是因为Facebook SDK的LoginManager期望使用android.support.v4.app.Fragment来代替。

You can do it by passing the activity , like this 您可以通过传递activity来做到这一点,就像这样

LoginManager.getInstance().logInWithReadPermissions(getActivity(), Arrays.asList("public_profile", "user_friends", "email"));

Please check the latest Facebook SDK: 请检查最新的Facebook SDK:

compile 'com.facebook.android:facebook-android-sdk:4.10.0'

It now supports standard fragment too. 现在,它也支持标准片段。 LoginManager has 3 functions now: LoginManager现在具有3个功能:

  1. For activity. 为了活动。
  2. For support fragment. 对于支持片段。
  3. For standard fragment. 对于标准片段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM