Fragment的Google登录未返回至应用 [英] Google Sign-In from Fragment is not returned to the app
问题描述
问题是来自Fragment的Google登录会关闭应用程序,并且永远不会调用Fragment或父Activity的onActivityResult
.当我以
The problem is Google Sign-In from Fragment closes the app and never calls onActivityResult
both Fragment or parent Activity. When I start signInIntent
as described in example from my Fragment, the app closes and Sign-In dialog appears. I can choose an account to Sign-In, but after that I see just my desktop instead of my app.
使用我的父级活动配置的登录API客户端:
Sign-In API Client configured using my parent Activity:
googleApiClient = new GoogleApiClient.Builder(activity)
.enableAutoManage(activity /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.addConnectionCallbacks(this)
.build();
添加:片段父活动不是启动活动.在启动活动中,我进行Facebook登录操作,并在用户已经登录的情况下立即finish
.问题可以在这个地方吗?
Add: Fragment parent Activity is not launch activity. In my launch activity I do Facebook sign-in operation and immediately finish
it in case of a user already signed. Can the issue be in this place?
推荐答案
该问题的原因是Intent.FLAG_ACTIVITY_NO_HISTORY
旨在从登录Activity启动第二个Activity(Fragment的父级).另外,您可以从Fragment调用signInIntent
并在那里获取onActivityResult
(您无需从Activity调用此意图).
The issue was of Intent.FLAG_ACTIVITY_NO_HISTORY
used in intent to launch the second Activity (parent of Fragment) from login Activity. Also, you can call signInIntent
from Fragment and get onActivityResult
there (you don't need call this intent from Activity).
这篇关于Fragment的Google登录未返回至应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!