2017-02-27 139 views
0

想更多地瞭解谷歌播放服務的設計。谷歌播放服務的設計

喜歡使用它,我們需要創建一個GoogleApiClient對象(見下面的代碼),然後我們需要添加我們感興趣的API。

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

可以任何身體幫助我,他們是如何構建它的整個機制。 這篇文章是幫助完整 http://wiresareobsolete.com/2016/06/play-services-complexity/ 但我想了解更多的細節。

回答

0

你可以嘗試的官方文件 - Overview of Google Play Services

隨着谷歌播放服務,您的應用程序可以利用最新的,谷歌驅動的功能,如地圖,Google +等,具有自動平臺更新分佈式作爲APK通過Google Play商店。這可讓您的用戶更快獲得更新,並且更容易整合Google提供的最新版本。

enter image description here

顯示谷歌API客戶端如何提供連接和撥打電話到任何可用的谷歌Play服務,如谷歌玩遊戲和谷歌驅動器的接口一個例證。

要開始使用,您必須先爲Android SDK安裝Google Play服務庫(修訂版15或更高版本)。如果您還沒有這樣做,請按照設置Google Play服務SDK中的說明操作。

下面是實現回調接口,並將它們添加到谷歌API客戶端的活動代碼示例:

import com.google.android.gms.common.api.GoogleApiClient; 
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener; 
import gms.drive.*; 
import android.support.v4.app.FragmentActivity; 

public class MyActivity extends FragmentActivity 
     implements OnConnectionFailedListener { 
    private GoogleApiClient mGoogleApiClient; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

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

     // ... 
    } 

    @Override 
    public void onConnectionFailed(ConnectionResult result) { 
     // An unresolvable error has occurred and a connection to Google APIs 
     // could not be established. Display an error message, or handle 
     // the failure silently 

     // ... 
    } 
} 
+0

我知道如何使用谷歌播放服務,但所有這些文件是在告訴只要。但一些人傾向於瞭解他們如何實施谷歌播放服務的內部細節。他們使用了什麼數據結構。他們考慮什麼設計考慮等等 – user2885066