웨어러블 데이터 계층 접근


데이터 계층 API를 호출하기 위해, Google Play 서비스 API의 주 진입점인 GoogleApiClient의 인스턴스를 생성하라.

GoogleApiClient는 클라이언트의 인스턴스를 생성하기 쉽도록 만들어주는 빌더를 제공한다. 최소한의 GoogleApiClient는 다음과 같다:

메모: 일단, 이 최소한의 클라이언트는 시작하기에 충분하다. 그러나, GoogleApiClient 생성에 관한 정보, 해당 콜백의 구현, 그리고 오류 사례에 대한 처리 방법에 관한 더 많은 정보를 위해 Accessing Google Play services APIs를 참조하라.

GoogleApiClient mGoogleAppiClient = new GoogleApiClient.Builder(this)
       
.addConnectionCallbacks(new ConnectionCallbacks() {
               
@Override
               
public void onConnected(Bundle connectionHint) {
                   
Log.d(TAG, "onConnected: " + connectionHint);
                   
// Now you can use the data layer API
               
}
               
@Override
               
public void onConnectionSuspended(int cause) {
                   
Log.d(TAG, "onConnectionSuspended: " + cause);
               
}
       
})
       
.addOnConnectionFailedListener(new OnConnectionFailedListener() {
               
@Override
               
public void onConnectionFailed(ConnectionResult result) {
                   
Log.d(TAG, "onConnectionFailed: " + result);
               
}
           
})
       
.addApi(Wearable.API)
       
.build();

당신은 데이터 계층 API를 사용하기 전에, Accessing Google Play services APIs에서 설명한대로 connect() 메소드를 호출하여 당신의 클라이언트상의 연결을 시작하라. 시스템이 당신의 클라이언트에 대해 onConnected()를 호출했을 때, 당신은 데이터 계층 API를 사용할 준비가 된 것이다.

'Android - Building Apps for Wearables > Sending and Syncing Data' 카테고리의 다른 글

Handling Data Layer Events  (0) 2014.09.10
Sending and Receiving Messages  (0) 2014.09.10
Transferring Assets  (0) 2014.09.10
Syncing Data Items  (0) 2014.09.10
Sending and Syncing Data  (0) 2014.09.10
Posted by 레미파
,