我已经创建了解析应用程序。创建了一个facebook应用程序,记下了ApplicationId,Hashkeys,并更新了解析应用程序。以下是我为实现FB集成所做的代码片段。
首先在应用程序类中使用Parse.com初始化Facebook应用程序,如下所示:
ParseFacebookUtils.initialize(FB_APPLICATION_ID);我已经更新了android清单如下:
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<activity
android:name=".LoginActivity"
android:label="@string/title_activity_login" >
</activity>以下是登录Parse.com的代码
@Override public void完成(最终ParseUser用户,ParseException异常){ if (用户!= null) { if (user.isNew()) { System.out.println(ParseFacebookUtils .getSession().getAccessToken();}
startActivity(new Intent(LoginActivity.this,
HomeScreenActivity.class));
getSharedPreferences(PREF_NAME, 0).edit()
.putString(TWITTER_LOGIN, LOGIN_PLATFORM)
.commit();
getSharedPreferences(PREF_NAME, 0).edit()
.putBoolean(IS_USER_LOGGED, true).commit();
} else {
}
}
});然而,当这段代码在中执行时,会显示加载并返回到相同的屏幕,而不是显示facebook对话框。
Saw logcat中包含以下内容:
Displayed com.facebook.katana/.ProxyAuthDialog: +229ms (total +247ms)
Activity com.facebook.katana.ProxyAuthDialog has leaked ServiceConnection com.android.org.chromium.com.googlecode.eyesfree.braille.selfbraille.SelfBrailleClient$Connection@423302c8 that was originally bound here02-08 19:45:25.412: E/ActivityThread(21197):android.app.ServiceConnectionLeaked: Activity com.facebook.katana.ProxyAuthDialog泄漏了最初绑定在此处的ServiceConnection that请帮助
发布于 2015-02-08 22:38:01
好吧,我解决了这个问题。您需要覆盖onActivityResult
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
ParseFacebookUtils.finishAuthentication(requestCode, resultCode, data);
}https://stackoverflow.com/questions/28395017
复制相似问题