@@ -63,7 +63,7 @@ private WearSocket() {
63
63
//Setup and State Handling
64
64
//********************************************************************
65
65
66
- public void setupAndConnect (Context context , final String capability ) {
66
+ public void setupAndConnect (final Context context , final String capability ) {
67
67
this .context = context ;
68
68
this .capability = capability ;
69
69
Log .d (TAG , "Starting up Google Api Client" );
@@ -83,7 +83,9 @@ public void onConnectionSuspended(int i) {
83
83
.addOnConnectionFailedListener (new GoogleApiClient .OnConnectionFailedListener () {
84
84
@ Override
85
85
public void onConnectionFailed (ConnectionResult result ) {
86
- showErrorAndCloseApp ("Error, cannot connect" , true );
86
+ String message = "Cannot start google api client" ;
87
+ Toast .makeText (context ,message ,Toast .LENGTH_SHORT ).show ();
88
+ throw new RuntimeException ("Cannot start google api client" );
87
89
}
88
90
})
89
91
.addApi (Wearable .API )
@@ -120,12 +122,15 @@ public void run() {
120
122
121
123
private String findBestNodeId (Set <Node > nodes ) {
122
124
String bestNodeId = null ;
125
+ Log .d (TAG ,"Found Set of nodes: " +nodes .size ());
123
126
for (Node node : nodes ) {
124
127
if (node .isNearby ()) {
125
- bestNodeId = node .getId ();
128
+ Log .d (TAG ,"Found nearby node: " +node .getId ());
129
+ return node .getId ();
126
130
}
127
131
bestNodeId = node .getId ();
128
132
}
133
+ Log .d (TAG ,"No nearby node found, settling for: " +bestNodeId );
129
134
return bestNodeId ;
130
135
}
131
136
0 commit comments