2017-01-12 68 views
1

我正在使用GoogleAPI的Android應用程序中工作。在OnCreate()方法中,與GoogleApiClient連接,但已經連接

我連接GoogleApiClient。我的問題是:假設,GoogleApiClinetconnected。現在,如果用另一種方法,我再次請求與GoogleApiClient的連接,它是否會對我的應用程序的speed & performance產生任何問題?

我再次使用Geofencing也。假設有些地方註冊了Geofence。我再次調用方法註冊&相同的地方,它不會產生任何問題。但我的問題是,它會在內部造成什麼傷害或使我的申請slow

回答

1

不,它不會對您的應用程序造成任何傷害。我建議你查看這個Accessing Google APIs文檔。

在此聲明,如果要連接到Google Play服務庫中提供的某個Google API(例如Google登錄,遊戲或雲端硬盤),則需要創建一個GoogleApiClient(「Google API客戶端」)。 Google API客戶端爲所有Google Play服務提供了一個通用入口點,並管理用戶設備與每項Google服務之間的網絡連接。

以下是使用GoogleApiClient以及多個API和範圍的示例代碼。

GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this) 
    .enableAutoManage(this /* FragmentActivity */, 
         this /* OnConnectionFailedListener */) 
    .addApi(Drive.API) 
    .addScope(Drive.SCOPE_FILE) 
    .build(); 

您可以通過附加到addApi()addScope()其他調用添加多個API和多個範圍相同的GoogleApiClient。

如果您想手動連接GoogleApiClient,那麼此文檔的這個part可以幫助您。

相關問題