Quantcast
Channel: kenji matsuokaのニッキ
Viewing all articles
Browse latest Browse all 342

ウェアラブルデータレイヤーにアクセスする

$
0
0
ウェアラブル向けアプリを作る 目次
原文

データレイヤーAPIを呼ぶためにGoogle Play servicesAPI群の主なエントリーポイントで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);
// データレイヤー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を使う準備が完了します。


Except as noted, this content is licensed under Creative Commons Attribution 2.5. For details and restrictions, see the Content License.

Viewing all articles
Browse latest Browse all 342

Trending Articles