2016-03-04 81 views
0

我爲我的android應用程序使用GooglePlayServices。我將使用Google+ Api & LocationServices Api。因此,從Google的文檔中,我使用addApi(Auth.GOOGLE_SIGN_IN_API),addApi(LocationServices.API)構建了GoogleApiClient。每次用戶啓動應用程序時,我都會使用Google+ api,但在極少數情況下(一次啓動100次)使用LocationServices。那麼實施的最佳方式是什麼?GoogleApiClient用於多個Api的

通過添加兩個Api創建一個GoogleApiClient?或
爲這兩個API分別創建兩個GoogleApiClient?

+1

我有同樣的問題,增加更多的API,你已經知道答案嗎? –

+0

未找到解決方案 –

回答

0

如果需要

mGoogleApiClient = new GoogleApiClient.Builder(this) 
       .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) 
       .addConnectionCallbacks(this) 
       .addOnConnectionFailedListener(this) 
       .addApi(LocationServices.API) 
       .addApi(Auth.GOOGLE_SIGN_IN_API, gso) 
       // Add more APIs, as needed 
       .build();