本文整理匯總了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;
}
示例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;
}
示例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);
}
}
示例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();
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}