简体   繁体   English

无需ParseUI Android即可解析用户登录Facebook

[英]Parse User Login Facebook without ParseUI Android

I want to implement a user Login just with Facebook on my own witouth using the ParseUI. 我想使用ParseUI以自己的方式仅通过Facebook实现用户登录。

Here is what I did: Main Screen checks if ParseUsers == null If ParseUser ist null it redirects to the LoginActivity. 这是我所做的:主屏幕检查ParseUsers == null如果ParseUser ist为null,它将重定向到LoginActivity。

For this activity I just want to show the Login with Facebook Button. 对于此活动,我只想显示“使用Facebook登录”按钮。 And thats my Question: If I use the provided tutorial from Facebook and use the xml Code: 那就是我的问题:如果我使用Facebook提供的教程并使用xml代码:

<com.facebook.login.widget.LoginButton
android:id="@+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp" />  

The Facebook sdk is used to login and not the Parse SDK which creates a Parse User and likes it. Facebook sdk用于登录,而不是用于创建Parse User并喜欢的Parse SDK。

My Question now is where do I get the Facebook Button from? 我的问题是,我从哪里获得Facebook Button? Do I need to create a simple Button with the Facebook Login image or is it possible to use the Facebook button as described without calling the Facebook login routine automatically and instead just call my own onClick function? 我是否需要使用Facebook登录图像创建一个简单的Button,还是可以按照说明使用Facebook按钮,而无需自动调用Facebook登录例程,而只需调用我自己的onClick函数?

Thanks! 谢谢!

You have the answer in the ParseUI-Android sample project . 您可以在ParseUI-Android示例项目中找到答案。 They do it using a regular button : 他们使用常规按钮执行此操作:

<Button
    android:id="@+id/facebook_login"
    style="@style/ParseLoginUI.Button.ThirdPartyLogin"
    android:layout_marginTop="@dimen/com_parse_ui_small_vertical_spacing"
    android:background="@drawable/com_parse_ui_facebook_login_button_background_selector"
    android:drawableLeft="@drawable/com_parse_ui_facebook_login_logo"
    android:text="@string/com_parse_ui_facebook_login_button_label"
    android:visibility="gone" />

To which they attach an onClickListener 他们附上一个onClickListener

private void setUpFacebookLogin() {
    facebookLoginButton.setVisibility(View.VISIBLE);

    if (config.getFacebookLoginButtonText() != null) {
        facebookLoginButton.setText(config.getFacebookLoginButtonText());
    }

    facebookLoginButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            loadingStart(false); // Facebook login pop-up already has a spinner
            if (config.isFacebookLoginNeedPublishPermissions()) {
                ParseFacebookUtils.logInWithPublishPermissionsInBackground(getActivity(),
                config.getFacebookLoginPermissions(), facebookLoginCallbackV4);
            } else {
                ParseFacebookUtils.logInWithReadPermissionsInBackground(getActivity(),
                config.getFacebookLoginPermissions(), facebookLoginCallbackV4);
            }
        }
    });
}

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

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