Establishing connections for the mobile activity
Until now, we have created our project and the user interface for the mobile in our application. Also, we have set up our permissions so that our application can communicate with the Internet and Google Play Services.
In order for our app to communicate between the handheld and the Android wearable, we will need to establish a connection:
From the Project Navigator window, expand the mobile section, select, and expand the java section.
Next, double-click to open
MobileActivity.java
, and add the following code snippet:public class MobileActivity extends ActionBarActivity { private GoogleApiClient mGoogleApiClient; private static final String LOG_TAG = "MobileActivity"; // establishes a connection between the mobile and wearable private void initGoogleApiClient() { if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) { Log.d(LOG_TAG, "Connected"); } else { // Creates a new GoogleApiClient...