When should I disconnect GoogleApiClient (Android)

跟風遠走 提交于 2019-12-21 20:29:09

问题


In my android app, I have 3 login options. Google+, Facebook, and my own login option. I've implemented all 3.

I've implemented Google+ login using the steps outlined here. Server side access is enabled.

I get the one time authorization code and pass it to my own api. Once I've received the authorization code, is there any reason to keep GoogleApiClient connected?

I have a similar question for Facebook Session here.


回答1:


There is no reason to keep connected to the GoogleApiClient unless you plan on directly calling one of its APIs later. Once you have the authorization code, you can close the GoogleApiClient if you want.

What does doing this early get you? It clears a binder connection a bit earlier and allows the com.google.android.gms process to be removed from memory (it probably won't be removed from memory anyway for a while anyway on mid-to-high end phones) a bit sooner.

I wouldn't worry about this. As long as you close the GoogleApiClient before the end of Activity#onStop everything should be fine.



来源:https://stackoverflow.com/questions/30043349/when-should-i-disconnect-googleapiclient-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!