Esempio n. 1
0
 @Override // ConnectionCallbacks
 public void onConnected(Bundle connectionHint) {
   mResolvingError = false;
   mStartActivityBtn.setEnabled(true);
   mSendPhotoBtn.setEnabled(mCameraSupported);
   Wearable.DataApi.addListener(mMobvoiApiClient, this);
   Wearable.MessageApi.addListener(mMobvoiApiClient, this);
   Wearable.NodeApi.addListener(mMobvoiApiClient, this);
 }
Esempio n. 2
0
 @Override
 protected void onStop() {
   if (!mResolvingError) {
     Wearable.DataApi.removeListener(mMobvoiApiClient, this);
     Wearable.MessageApi.removeListener(mMobvoiApiClient, this);
     Wearable.NodeApi.removeListener(mMobvoiApiClient, this);
     mMobvoiApiClient.disconnect();
   }
   super.onStop();
 }
Esempio n. 3
0
  private Collection<String> getNodes() {
    HashSet<String> results = new HashSet<String>();
    NodeApi.GetConnectedNodesResult nodes =
        Wearable.NodeApi.getConnectedNodes(mMobvoiApiClient).await();

    for (Node node : nodes.getNodes()) {
      results.add(node.getId());
    }

    return results;
  }
Esempio n. 4
0
 @Override // OnConnectionFailedListener
 public void onConnectionFailed(ConnectionResult result) {
   if (mResolvingError) {
     // Already attempting to resolve an error.
     return;
   } else if (result.hasResolution()) {
     try {
       mResolvingError = true;
       result.startResolutionForResult(this, REQUEST_RESOLVE_ERROR);
     } catch (IntentSender.SendIntentException e) {
       // There was an error with the resolution intent. Try again.
       mMobvoiApiClient.connect();
     }
   } else {
     mResolvingError = false;
     mStartActivityBtn.setEnabled(false);
     mSendPhotoBtn.setEnabled(false);
     Wearable.DataApi.removeListener(mMobvoiApiClient, this);
     Wearable.MessageApi.removeListener(mMobvoiApiClient, this);
     Wearable.NodeApi.removeListener(mMobvoiApiClient, this);
   }
 }