@Override protected void onStart() { super.onStart(); if (!mResolvingError) { mMobvoiApiClient.connect(); } }
@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(); }
@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); } }
public void onSendPhotoClick(View view) { if (null != mImageBitmap && mMobvoiApiClient.isConnected()) { sendPhoto(toAsset(mImageBitmap)); } }