Back to project page Android.Wear.Message.
The source code is released under:
MIT License
If you think the Android project Android.Wear.Message listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.iamnbty.androidwear.helper; /* www.j a va2s . co m*/ import android.content.Context; import android.os.Bundle; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.Api; import com.google.android.gms.common.api.GoogleApiClient; public class GoogleApiHelper implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private GoogleApiClient mGoogleApiClient; private Callback mCallback; /** * @param context Context * @param apis Wearable.API, Plus.API */ public GoogleApiHelper(Context context, Callback callback, Api... apis) { // store callback mCallback = callback; // build Google Api Client GoogleApiClient.Builder builder = new GoogleApiClient.Builder(context, this, this); for (Api api : apis) { builder.addApi(api); } mGoogleApiClient = builder.build(); } public void activate() { mGoogleApiClient.connect(); } public void deactivate() { mGoogleApiClient.disconnect(); } @Override public void onConnected(Bundle bundle) { mCallback.onGoogleApiClientReady(); } @Override public void onConnectionSuspended(int result) { mCallback.onGoogleApiClientNotReady(); } @Override public void onConnectionFailed(ConnectionResult connectionResult) { } public GoogleApiClient getGoogleApiClient() { return mGoogleApiClient; } public interface Callback { public void onGoogleApiClientReady(); public void onGoogleApiClientNotReady(); } }