Java 类com.google.android.gms.wearable.CapabilityClient 实例源码

项目:android-DataLayer    文件:MainActivity.java   
/**
 * Find the connected nodes that provide at least one of the given capabilities
 */
private void showNodes(final String... capabilityNames) {

    Task<Map<String, CapabilityInfo>> capabilitiesTask =
            Wearable.getCapabilityClient(this)
                    .getAllCapabilities(CapabilityClient.FILTER_REACHABLE);

    capabilitiesTask.addOnSuccessListener(new OnSuccessListener<Map<String, CapabilityInfo>>() {
        @Override
        public void onSuccess(Map<String, CapabilityInfo> capabilityInfoMap) {
            Set<Node> nodes = new HashSet<>();

            if (capabilityInfoMap.isEmpty()) {
                showDiscoveredNodes(nodes);
                return;
            }
            for (String capabilityName : capabilityNames) {
                CapabilityInfo capabilityInfo = capabilityInfoMap.get(capabilityName);
                if (capabilityInfo != null) {
                    nodes.addAll(capabilityInfo.getNodes());
                }
            }
            showDiscoveredNodes(nodes);
        }
    });
}
项目:android-DataLayer    文件:MainActivity.java   
@Override
public void onResume() {
    super.onResume();
    mDataItemGeneratorFuture = mGeneratorExecutor.scheduleWithFixedDelay(
            new DataItemGenerator(), 1, 5, TimeUnit.SECONDS);

    mStartActivityBtn.setEnabled(true);
    mSendPhotoBtn.setEnabled(mCameraSupported);

    // Instantiates clients without member variables, as clients are inexpensive to create and
    // won't lose their listeners. (They are cached and shared between GoogleApi instances.)
    Wearable.getDataClient(this).addListener(this);
    Wearable.getMessageClient(this).addListener(this);
    Wearable.getCapabilityClient(this)
            .addListener(
                    this, Uri.parse("wear://"), CapabilityClient.FILTER_REACHABLE);
}
项目:cordova-androidwear    文件:WearProviderService.java   
@Override
public void onCreate() {
    super.onCreate();

    LOGD(TAG, "onCreate");
    Wearable.getMessageClient(this).addListener(this);
    Wearable.getCapabilityClient(this)
            .addListener(
                    this, Uri.parse("wear://"), CapabilityClient.FILTER_REACHABLE);

    Thread mBackgroundThread = new BackgroundThread();
    mBackgroundThread.start();
}
项目:cordova-androidwear    文件:WearProviderService.java   
private void loadNodes() {
    Task<CapabilityInfo> capabilityTask = Wearable.getCapabilityClient(this)
            .getCapability(CORDOVA_CAPABILITY, CapabilityClient.FILTER_REACHABLE);
    capabilityTask.addOnSuccessListener(new OnSuccessListener<CapabilityInfo>() {
        @Override
        public void onSuccess(CapabilityInfo capabilityInfo) {
            WearProviderService.this.onCapabilityChanged(capabilityInfo);
        }
    });
}
项目:android-DataLayer    文件:MainActivity.java   
@Override
protected void onResume() {
    super.onResume();

    // Instantiates clients without member variables, as clients are inexpensive to create and
    // won't lose their listeners. (They are cached and shared between GoogleApi instances.)
    Wearable.getDataClient(this).addListener(this);
    Wearable.getMessageClient(this).addListener(this);
    Wearable.getCapabilityClient(this)
            .addListener(
                    this, Uri.parse("wear://"), CapabilityClient.FILTER_REACHABLE);
}