i developing an app for android wear. Below code with explanation of the problem
if(mGoogleApiClient.isConnected()){
K.i(\"Always called!\");
Here's a full code of how to check it:
add this to the gradle file:
compile 'com.google.android.gms:play-services-wearable:9.4.0'
And use this function to check if a wearable is connected:
@WorkerThread
public boolean isWearableAvailable(Context context) {
NotificationManagerCompat.from(context).cancel(NotificationType.WEARABLE_IN_CALL.getId());
final GoogleApiClient googleApiClient = new Builder(context).addApi(Wearable.API).build();
final ConnectionResult connectionResult = googleApiClient.blockingConnect();
if (connectionResult.isSuccess()) {
NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(googleApiClient).await();
for (Node node : nodes.getNodes()) {
if (node.isNearby())
return true;
}
}
return false;
}