I have an Android app with Facebook login integrated with parse.com. Unfortunately, when a user logs in with facebook the authorize web view gets launched twice.
I have searched extensively for a proper solution and have not found one. I have played with almost all the app settings on the facebook side as well.
Here is where I am calling the login from my LoginActivity. I do not know where the other login is being launched.
private void onLoginButtonClicked() {
NativeLoginActivity.this.progressDialog = ProgressDialog.show(NativeLoginActivity.this, "", "Logging in...", true);
List<String> permissions = Arrays.asList("public_profile", "user_friends", "user_about_me", "user_relationships", "user_birthday",
"user_location");
ParseFacebookUtils.logIn(permissions, this, new LogInCallback() {
@Override
public void done(ParseUser user, ParseException err) {
//NativeLoginActivity.this.progressDialog.dismiss();
if (user == null) {
Log.d(TAG, "Uh oh. The user cancelled the Facebook login.");
} else if (user.isNew()) {
showUserDetailsActivity();
} else {
Log.d(TAG, "User logged in through Facebook!");
showUserDetailsActivity();
}
}
});
}
Here is the login button in xml:
<com.facebook.widget.LoginButton
android:id="@+id/fbLoginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:layout_marginBottom="10dp"/>
Here are the settings in my manifest:
<activity
android:name="com.facebook.LoginActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/app_id" />
Facebook settings: Class name is my MainActivity, Single Sign On is enabled, App Status is public
I do not understand where the additional login call is coming from. Any help is appreciated that gets me towards a solution. I am relatively new to Android.
SOLVED
There is a difference between using a standard button in xml (as provided in parse documentation) and using the facebook widget button (as provided in the facebook documentation)
The facebook widget has some ingrained functionality that launches the login (not sure how).
The standard button requires you to attach a listener, call the parse facebook login function.
As I had the listenar and the parse call in addition to the widget, login was getting called twice.
changed this: < com.facebook.widget.LoginButton.../>
to this:
<Button
android:id="@+id/fbLoginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:gravity="center_horizontal"
android:background="@drawable/button_login"
android:text="@string/login"
android:textColor="#fff" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With