gpt4 book ai didi

安卓 FacebookException : Login attempt failed

转载 作者:行者123 更新时间:2023-11-29 15:10:16 26 4
gpt4 key购买 nike

我正在使用 ParseFacebookUtils 从 Facebook 登录我的应用。

LoginActivity 的 onCreate:

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);

loginButton = (Button)findViewById(R.id.loginButton);
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ParseFacebookUtils.logInWithReadPermissionsInBackground(LoginActivity.this,
Arrays.asList("public_profile", "email", "user_photos", "user_birthday"),
new LogInCallback() {
@Override
public void done(ParseUser user, ParseException e) {
if (user == null) {
Log.d(TAG, "Uh oh. The user cancelled the Facebook login.");
} else if (user.isNew()) {
Log.d(TAG, "User signed up and logged in through Facebook!");
} else {
Log.d(TAG, "User logged in through Facebook!");
}
}
}
);
}
});
}

应用类onCreate:

public void onCreate() {
super.onCreate();

Parse.initialize(this, app_id, client_key);
FacebookSdk.sdkInitialize(getApplicationContext());
ParseFacebookUtils.initialize(getApplicationContext());
}

崩溃错误:

com.facebook.FacebookException: Log in attempt failed: LoginActivity could not be started
at com.facebook.login.LoginManager.startLogin(LoginManager.java:382)
at com.facebook.login.LoginManager.logInWithReadPermissions(LoginManager.java:262)
at com.parse.FacebookAuthenticationProvider.authenticateAsync(FacebookAuthenticationProvider.java:150)
at com.parse.ParseAuthenticationProvider.logInAsync(ParseAuthenticationProvider.java:57)
at com.parse.ParseFacebookUtils.logInAsync(ParseFacebookUtils.java:259)
at com.parse.ParseFacebookUtils.logInWithReadPermissionsInBackground(ParseFacebookUtils.java:155)
at com.parse.ParseFacebookUtils.logInWithReadPermissionsInBackground(ParseFacebookUtils.java:167)
at com.example.app.LoginActivity$1.onClick(LoginActivity.java:48)
at android.view.View.performClick(View.java:4756)
at android.view.View$PerformClick.run(View.java:19749)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

点击登录按钮时,我不断遇到上述崩溃问题。

关于如何解决这个问题有什么想法吗?

我已经在 strings.xml 中设置了 Facebook 和 Parse 的客户端 ID

更新:

Facebook SDK v4.0.1

自定义按钮onClick()

最佳答案

@kRiZ:是的。您忘记将 com.facebook.FacebookActivity Activity 添加到 AndroidManifest.xml.

此 Activity 是整个 Facebook SDK 的必要组成部分,但不能直接使用。将此 Activity 添加到您的 AndroidManifest.xml 以确保正确处理 Facebook SDK 功能。

Reference要使用 Facebook 登录或共享,还要将 FacebookActivity 添加到 list 中:

<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:label="@string/app_name" />

<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>

@string/facebook_app_id 是您的 Facebook 应用程序 ID

这就是 facebook 授权 流程的运作方式。

enter image description here

关于安卓 FacebookException : Login attempt failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32447713/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com