[英]How does UiLifeCycleHelper utilize LoginButton in facebook SDK
我正在尝试使用facebook SDK学习android开发。
今天,我尝试了其中的“登录”部分。 但是,问题是我在这方面有很多困惑,因为我不了解uiLifeCycleHelper和LoginButton是如何交互的。
从样本中:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context="co.chintan.fbtest.SplashFragment"
>
<com.facebook.widget.LoginButton
android:id="@+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="130dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/login_button"
android:text="@string/get_started"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"/>
</RelativeLayout>
这是登录屏幕,从代码中可以明显看出它具有一个登录按钮。
主要活动流程如下:
现在我的问题是,uiLifeCycleHelper如何使用在布局xml中创建的LoginButton,因为在我创建的MainActivity类中没有实现LoginButton,因此即使在我单击时,似乎也存在LoginButton的侦听器登录按钮,我可以登录并创建会话并加载经过身份验证的用户界面。
我看到了SDK源,但即使在那里也看不到loginButton的任何侦听器。
uiLifecycleHelper.onActivityResult方法将登录结果传递到Session对象。 LoginButton包含一个SessionTracker(SDK中的一个内部类),用于跟踪会话更改,这是如何知道登录成功的方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.