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


Java Node.getDisplayName方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: getNodeName

import com.google.android.gms.wearable.Node; //導入方法依賴的package包/類
public String getNodeName(String id) {
    Node node = getLastConnectedNodeById(id);
    if (node != null) {
        return node.getDisplayName();
    } else {
        if (id == null || id.equals(DEFAULT_NODE_ID)) {
            return Build.MODEL;
        } else {
            return id;
        }
    }
}
 
開發者ID:Steppschuh,項目名稱:Sensor-Data-Logger,代碼行數:13,代碼來源:GoogleApiMessenger.java

示例5: 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.getDisplayName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。