コード例 #1
0
ファイル: MainActivity.java プロジェクト: sn0opy1/HACKATHON
 @Override
 protected void onPause() {
   super.onPause();
   if (mGoogleApiClient != null) Wearable.DataApi.removeListener(mGoogleApiClient, this);
   if (mSensorManager != null) mSensorManager.unregisterListener(this);
   if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) mGoogleApiClient.disconnect();
   if (mHeadTracker != null) mHeadTracker.stopTracking();
 }
コード例 #2
0
  /**
   * Closes the connection to Google Play services. No calls can be made using this {@link
   * #mGoogleApiClient} after calling this method. Any method calls that haven't executed yet will
   * be canceled. That is onResult(Result) won't be called, if connection to the service hasn't been
   * established yet all calls already made will be canceled.
   */
  public void disConnect() {
    try {
      if (mDataListener != null) {
        Wearable.DataApi.removeListener(mGoogleApiClient, mDataListener);
      }
      if (mMessageListener != null) {
        Wearable.MessageApi.removeListener(mGoogleApiClient, mMessageListener);
      }
      if (mNodeListener != null) {
        Wearable.NodeApi.removeListener(mGoogleApiClient, mNodeListener);
      }

      if ((mGoogleApiClient != null)
          && (mGoogleApiClient.isConnected() || mGoogleApiClient.isConnecting())) {
        mGoogleApiClient.disconnect();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #3
0
 @Override
 protected void onStop() {
   super.onStop();
   Wearable.DataApi.removeListener(mGoogleApiClient, this);
   mGoogleApiClient.disconnect();
 }