类容:手持端app 点击按钮,手表端显示点击次数
1. 设备间通过GoogleApiClient建立连接,若需监听连接是否成功,需
继承GoogleApiClient.ConnectionCallbacks,GoogleApiClient.OnConnectionFailedListener,
此处采用MessageApi发送,继承DataApi.DataListener,MessageApi.MessageListener监听。
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Wearable.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
2. 在Activity 中启动连接
@Override
protected void onStart() {
//start connect the node you want
mGoogleApiClient.connect();
supe