你可以这样使用它...
mBtnFacebook = (LoginButton) v.findViewById(R.id.btn_facebook);
mBtnFacebook.setReadPermissions(Arrays.asList("email", "user_birthday"));
mBtnFacebook.setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK);
接着
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode != 0) {
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
Session.openActiveSession(this, true, new Session.StatusCallback() {
@Override
public void call(final Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
}
}
});
}
}
});
}
}
确保你在清单中有这个
<activity android:name="com.facebook.LoginActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:label="@string/app_name" />
也
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>
这个标签在标签内
应该是这样的:)