當前位置: 首頁>>代碼示例>>Java>>正文


Java Node.getId方法代碼示例

本文整理匯總了Java中com.google.android.gms.wearable.Node.getId方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.getId方法的具體用法?Java Node.getId怎麽用?Java Node.getId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.android.gms.wearable.Node的用法示例。


在下文中一共展示了Node.getId方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doInBackground

import com.google.android.gms.wearable.Node; //導入方法依賴的package包/類
@Override
protected String doInBackground(GoogleApiClient... params) {
  final List<Node> connectedNodes = Wearable.NodeApi.getConnectedNodes(client).await().getNodes();
  for (Node connectedNode : connectedNodes) {
    if (connectedNode.isNearby()) {
      return connectedNode.getId();
    }
  }
  return null;
}
 
開發者ID:bevkoski,項目名稱:react-native-android-wear-demo,代碼行數:11,代碼來源:MainActivity.java

示例2: pickBestNodeId

import com.google.android.gms.wearable.Node; //導入方法依賴的package包/類
private String pickBestNodeId(Set<Node> nodes) {
    String bestNodeId = null;
    // Find a nearby node or pick one arbitrarily
    for (Node node : nodes) {
        if (node.isNearby()) {
            return node.getId();
        }
        bestNodeId = node.getId();
    }
    return bestNodeId;
}
 
開發者ID:Hitesh880443,項目名稱:SunshineWithWear,代碼行數:12,代碼來源:MyDigitalWatchFace.java

示例3: onPeerConnected

import com.google.android.gms.wearable.Node; //導入方法依賴的package包/類
@Override
public void onPeerConnected(Node peer) {//Deprecated with BIND_LISTENER
    super.onPeerConnected(peer);
    String id = peer.getId();
    String name = peer.getDisplayName();
    Log.d(TAG, "onPeerConnected peer name & ID: " + name + "|" + id);
    mPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    sendPrefSettings();
    if (mPrefs.getBoolean("enable_wearG5", false) && !mPrefs.getBoolean("force_wearG5", false)) {
        stopBtService();
        ListenerService.requestData(this);
    }
}
 
開發者ID:NightscoutFoundation,項目名稱:xDrip,代碼行數:14,代碼來源:ListenerService.java

示例4: onPeerDisconnected

import com.google.android.gms.wearable.Node; //導入方法依賴的package包/類
@Override
public void onPeerDisconnected(Node peer) {//Deprecated with BIND_LISTENER
    super.onPeerDisconnected(peer);
    String id = peer.getId();
    String name = peer.getDisplayName();
    Log.d(TAG, "onPeerDisconnected peer name & ID: " + name + "|" + id);
    mPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    if (mPrefs.getBoolean("enable_wearG5", false)) {
        startBtService();
    }
}
 
開發者ID:NightscoutFoundation,項目名稱:xDrip,代碼行數:12,代碼來源:ListenerService.java

示例5: pickBestNodeId

import com.google.android.gms.wearable.Node; //導入方法依賴的package包/類
private String pickBestNodeId(Set<Node> nodes) {//TODO remove once confirm not needed
    String bestNodeId = null;
    // Find a nearby node or pick one arbitrarily
    for (Node node : nodes) {
        if (node.isNearby()) {
            return node.getId();
        }
        bestNodeId = node.getId();
    }
    return bestNodeId;
}
 
開發者ID:NightscoutFoundation,項目名稱:xDrip,代碼行數:12,代碼來源:ListenerService.java

示例6: setLocalNodeName

import com.google.android.gms.wearable.Node; //導入方法依賴的package包/類
private void setLocalNodeName () {
    forceGoogleApiConnect();
    NodeApi.GetLocalNodeResult localnodes = Wearable.NodeApi.getLocalNode(googleApiClient).await(60, TimeUnit.SECONDS);
    Node getnode = localnodes.getNode();
    localnode = getnode != null ? getnode.getDisplayName() + "|" + getnode.getId() : "";
    UserError.Log.d(TAG, "setLocalNodeName.  localnode=" + localnode);
}
 
開發者ID:NightscoutFoundation,項目名稱:xDrip,代碼行數:8,代碼來源:WatchUpdaterService.java

示例7: pickBestNodeId

import com.google.android.gms.wearable.Node; //導入方法依賴的package包/類
private String pickBestNodeId(Set<Node> nodes) {
    String bestNodeId = null;
    // Find a nearby node or pick one arbitrarily
    for (Node node : nodes) {
        System.out.println("Got possible node: " + node.getId());
        if (node.isNearby()) {
            return node.getId();
        }
        bestNodeId = node.getId();
    }
    return bestNodeId;
}
 
開發者ID:MVK16,項目名稱:stayawhile-android,代碼行數:13,代碼來源:MainActivity.java

示例8: getBestNodeId

import com.google.android.gms.wearable.Node; //導入方法依賴的package包/類
private String getBestNodeId(){
    String bestNodeId = null;
    // Find a nearby node or pick one arbitrarily
    NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).await();
    for (Node node : nodes.getNodes()) {
        if (node.isNearby()) {
            return node.getId();
        }
        bestNodeId = node.getId();
    }
    return bestNodeId;
}
 
開發者ID:MVK16,項目名稱:stayawhile-android,代碼行數:13,代碼來源:WearMessageHandler.java

示例9: pickBestNodeId

import com.google.android.gms.wearable.Node; //導入方法依賴的package包/類
@Nullable
private static String pickBestNodeId(@Nullable final Set<Node> nodes) {
    if (nodes == null || nodes.isEmpty()) {
        return null;
    }
    String bestNodeId = null;
    for (final Node node : nodes) {
        if (node.isNearby()) {
            return node.getId();
        }
        bestNodeId = node.getId();
    }
    return bestNodeId;
}
 
開發者ID:Doctoror,項目名稱:PainlessMusicPlayer,代碼行數:15,代碼來源:RemoteControl.java

示例10: doInBackground

import com.google.android.gms.wearable.Node; //導入方法依賴的package包/類
@Override
protected Void doInBackground(Void... voids) {
    if (googleApiClient.isConnected()) {
        if (System.currentTimeMillis() - lastRequest > 20 * 1000) { // enforce 20-second debounce period
            lastRequest = System.currentTimeMillis();
            //NodeApi.GetConnectedNodesResult nodes =
            //        Wearable.NodeApi.getConnectedNodes(googleApiClient).await();
            if (localnode == null || (localnode != null && localnode.isEmpty())) setLocalNodeName();
            CapabilityApi.GetCapabilityResult capabilityResult =
                    Wearable.CapabilityApi.getCapability(
                            googleApiClient, CAPABILITY_WEAR_APP,
                            CapabilityApi.FILTER_REACHABLE).await(GET_CAPABILITIES_TIMEOUT_MS, TimeUnit.MILLISECONDS);
            CapabilityInfo nodes;
            if (!capabilityResult.getStatus().isSuccess()) {
                Log.e(TAG, "doInBackground Failed to get capabilities, status: " + capabilityResult.getStatus().getStatusMessage());
                nodes = null;
            }
            else {
                nodes = capabilityResult.getCapability();
            }
            SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
            SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit();
            boolean enable_wearG5 = sharedPrefs.getBoolean("enable_wearG5", false);
            boolean force_wearG5 = sharedPrefs.getBoolean("force_wearG5", false);
            String node_wearG5 = mPrefs.getString("node_wearG5", "");

            if (nodes != null && nodes.getNodes().size() > 0) {
                updateWearSyncBgsCapability(nodes);
                int count = nodes.getNodes().size();
                Log.d(TAG, "doInBackground connected.  CapabilityApi.GetCapabilityResult mWearNodeID=" + (mWearNodeId != null ? mWearNodeId : "") + " count=" + count);//KS
                boolean isConnectedToWearable = false;
                for (Node peer : nodes.getNodes()) {

                    //onPeerConnected
                    String wearNode = peer.getDisplayName() + "|" + peer.getId();
                    Log.d(TAG, "CheckWearableConnected onPeerConnected peer name & ID: " + wearNode);
                    if (wearNode.equals(node_wearG5)) {
                        isConnectedToWearable = true;
                        sendPrefSettings();
                        break;
                    }
                    else if (node_wearG5.equals("")) {
                        isConnectedToWearable = true;
                        prefs.putString("node_wearG5", wearNode);
                        prefs.commit();
                        break;
                    }

                }
                sendPrefSettings();
                initWearData();
                if (enable_wearG5) {
                    //Only stop service if Phone will rely on Wear Collection Service
                    if (force_wearG5 && isConnectedToWearable) {
                        Log.d(TAG, "CheckWearableConnected onPeerConnected force_wearG5=true Phone stopBtService and continue to use Wear BT Collector");
                        stopBtService();
                    } else {
                        Log.d(TAG, "CheckWearableConnected onPeerConnected force_wearG5=false Phone startBtService");
                        startBtService();
                    }
                }
            }
            else {
                //onPeerDisconnected
                Log.d(TAG, "CheckWearableConnected onPeerDisconnected");
                if (sharedPrefs.getBoolean("wear_sync", false)) {
                    Log.d(TAG, "CheckWearableConnected onPeerDisconnected wear_sync=true Phone startBtService");
                    startBtService();
                }
            }
        } else {
            Log.d(TAG, "Debounce limit hit - not sending");
        }
    } else {
        Log.d(TAG, "Not connected for sending");
        googleApiClient.connect();
    }
    return null;
}
 
開發者ID:NightscoutFoundation,項目名稱:xDrip,代碼行數:80,代碼來源:WatchUpdaterService.java


注:本文中的com.google.android.gms.wearable.Node.getId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。