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


Java DataItem.getUri方法代碼示例

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


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

示例1: onDataChanged

import com.google.android.gms.wearable.DataItem; //導入方法依賴的package包/類
/**
 * Called whenever a new message sent by the Wearable.
 *
 * @param dataEvents buffer with transmitted data
 */
@Override
public void onDataChanged(DataEventBuffer dataEvents) {

    Log.i(TAG, "onDataChanged()");

    for (DataEvent dataEvent : dataEvents) {
        if (dataEvent.getType() == DataEvent.TYPE_CHANGED) {
            DataItem dataItem = dataEvent.getDataItem();
            Uri uri = dataItem.getUri();
            String path = uri.getPath();

            if (path.startsWith("/sensors/")) {
                if (SmartWatch.getInstance() != null) {
                    SmartWatch.getInstance().unpackSensorData(DataMapItem.fromDataItem(dataItem).getDataMap());
                }
            }
        }
    }
}
 
開發者ID:gradlman,項目名稱:SensorLib,代碼行數:25,代碼來源:SmartWatchListener.java

示例2: getBTFailed

import com.google.android.gms.wearable.DataItem; //導入方法依賴的package包/類
private void getBTFailed(DataItem dataItem) {
    dataItem.freeze();
    final Uri dataItemUri = dataItem.getUri();
    DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
    final int reason = dataMapItem.getDataMap().getInt("reason");
    if (debugMode) Log.d(TAG, "BT failed on wear, reason: " + reason);
    switch (reason) {
        case Statics.MY_BT_FAILED_NO_BT:
            Toast.makeText(getApplicationContext(), R.string.bt_failed_no_bt, Toast.LENGTH_LONG).show();
            break;
        case Statics.MY_BT_FAILED_NO_DEVICE:
            Toast.makeText(getApplicationContext(), R.string.bt_failed_no_device, Toast.LENGTH_LONG).show();
            break;
        case Statics.MY_BT_FAILED_USER:
            Toast.makeText(getApplicationContext(), R.string.bt_failed_user, Toast.LENGTH_LONG).show();
            break;
    }
    Wearable.DataApi.deleteDataItems(mGoogleApiClient, dataItemUri);
    prefs.edit().putBoolean(Statics.PREFUSEBTVARIO, false).apply();
    checkBoxBT.setChecked(false);
}
 
開發者ID:pulce,項目名稱:Wristglider,代碼行數:22,代碼來源:MainActivity.java

示例3: onDataChanged

import com.google.android.gms.wearable.DataItem; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
	for (DataEvent dataEvent : dataEvents) {
		if (dataEvent.getType() == DataEvent.TYPE_CHANGED) {
			DataItem dataItem = dataEvent.getDataItem();
			Uri uri = dataItem.getUri();
			String path = uri.getPath();

			if (path.startsWith("/sensors/")) {
				unpackSensorData(
						Integer.parseInt(uri.getLastPathSegment()),
						DataMapItem.fromDataItem(dataItem).getDataMap()
				);
			}
		}
	}
}
 
開發者ID:Drippler,項目名稱:wearabird,代碼行數:18,代碼來源:SensorReceiverService.java

示例4: ActiveRequest

import com.google.android.gms.wearable.DataItem; //導入方法依賴的package包/類
ActiveRequest(DataItem paramDataItem)
{
  this.uri = paramDataItem.getUri();
  List localList = this.uri.getPathSegments();
  if ((localList != null) && (localList.size() >= 3)) {
    this.packageName = ((String)localList.get(1));
  }
  for (this.requestId = ((String)localList.get(2));; this.requestId = null)
  {
    DataMap localDataMap = DataMap.fromByteArray(paramDataItem.getData());
    this.assetId = localDataMap.getString("assetIdentifier");
    this.destinationNodes = localDataMap.getStringArray("nodeIds");
    if ((this.destinationNodes == null) || (this.destinationNodes.length != 1)) {
      break;
    }
    this.nodeId = this.destinationNodes[0];
    return;
    this.packageName = null;
  }
  this.nodeId = null;
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:22,代碼來源:WearInstaller.java

示例5: onDataChanged

import com.google.android.gms.wearable.DataItem; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    super.onDataChanged(dataEvents);

    for (DataEvent dataEvent : dataEvents) {
        if (dataEvent.getType() == DataEvent.TYPE_CHANGED) {
            DataItem dataItem = dataEvent.getDataItem();
            Uri uri = dataItem.getUri();
            String path = uri.getPath();

            if (path.startsWith("/filter")) {
                DataMap dataMap = DataMapItem.fromDataItem(dataItem).getDataMap();
                int filterById = dataMap.getInt(DataMapKeys.FILTER);
                deviceClient.setSensorFilter(filterById);
            }
        }
    }
}
 
開發者ID:IBMCloudiLab,項目名稱:Bluemix-IoT-android-wear,代碼行數:19,代碼來源:MessageReceiverService.java

示例6: onDataChanged

import com.google.android.gms.wearable.DataItem; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.d(TAG, "onDataChanged()");

    for (DataEvent dataEvent : dataEvents) {
        if (dataEvent.getType() == DataEvent.TYPE_CHANGED) {
            DataItem dataItem = dataEvent.getDataItem();
            Uri uri = dataItem.getUri();
            String path = uri.getPath();

            if (path.startsWith("/sensors/")) {
                unpackSensorData(
                        Integer.parseInt(uri.getLastPathSegment()),
                        DataMapItem.fromDataItem(dataItem).getDataMap()
                );
            }
        }
    }
}
 
開發者ID:IBMCloudiLab,項目名稱:Bluemix-IoT-android-wear,代碼行數:20,代碼來源:SensorReceiverService.java

示例7: onDataChanged

import com.google.android.gms.wearable.DataItem; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.d(TAG, "onDataChanged()");

    for (DataEvent dataEvent : dataEvents) {
        if (dataEvent.getType() == DataEvent.TYPE_CHANGED) {
            DataItem dataItem = dataEvent.getDataItem();
            Uri uri = dataItem.getUri();
            String path = uri.getPath();

            if (path.startsWith("/sensors/")) {
                unpackSensorData(
                        Integer.parseInt(uri.getLastPathSegment()),
                        DataMapItem.fromDataItem(dataItem).getDataMap()
                );
            }

            if(path.startsWith("/expressionData/")){
                unpackExpressionData(DataMapItem.fromDataItem(dataItem).getDataMap());
            }
        }
    }
}
 
開發者ID:swandroid,項目名稱:swan-sense-studio,代碼行數:24,代碼來源:SensorReceiverService.java

示例8: onDataItemReceived

import com.google.android.gms.wearable.DataItem; //導入方法依賴的package包/類
private void onDataItemReceived(DataItem dataItem, int eventType){
    final Uri dataUri = dataItem.getUri();
    final String dataPath = dataUri.getPath();

    if (dataPath.startsWith(WearUtils.VEHICLE_DATA_PREFIX)) {
        final String dataType = dataPath.replace(WearUtils.VEHICLE_DATA_PREFIX, "");

        final byte[] eventData;
        if(eventType == DataEvent.TYPE_DELETED)
            eventData = null;
        else{
            eventData = dataItem.getData();
        }

        handler.post(new Runnable() {
            @Override
            public void run() {
                onVehicleDataUpdated(dataType, eventData);
            }
        });
    }
}
 
開發者ID:DroidPlanner,項目名稱:tower-wear,代碼行數:23,代碼來源:BaseActivity.java

示例9: onDataChanged

import com.google.android.gms.wearable.DataItem; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.d(TAG, "onDataChanged()");

    for (DataEvent dataEvent : dataEvents) {
        if (dataEvent.getType() == DataEvent.TYPE_CHANGED) {
            DataItem dataItem = dataEvent.getDataItem();
            Uri uri = dataItem.getUri();
            String path = uri.getPath();

            if (path.startsWith("/sensors/")) {
                unpackSensorData(
                    Integer.parseInt(uri.getLastPathSegment()),
                    DataMapItem.fromDataItem(dataItem).getDataMap()
                );
            }
        }
    }
}
 
開發者ID:pocmo,項目名稱:SensorDashboard,代碼行數:20,代碼來源:SensorReceiverService.java

示例10: deleteDataItems

import com.google.android.gms.wearable.DataItem; //導入方法依賴的package包/類
private void deleteDataItems(final DataItemBuffer dataItemList) {
    if (mGoogleApiClient.isConnected()) {
        for (final DataItem dataItem : dataItemList) {
            final Uri dataItemUri = dataItem.getUri();
            /*
             * In a real calendar application, this might delete the corresponding calendar
             * events from the calendar data provider. However, we simply delete the DataItem,
             * but leave the phone's calendar data intact for this simple sample.
             */
            Wearable.DataApi.deleteDataItems(mGoogleApiClient, dataItemUri)
                    .setResultCallback(new ResultCallback<DataApi.DeleteDataItemsResult>() {
                        @Override
                        public void onResult(DataApi.DeleteDataItemsResult deleteResult) {
                            if (deleteResult.getStatus().isSuccess()) {
                                appendLog("Successfully deleted data item: " + dataItemUri);
                            } else {
                                appendLog("Failed to delete data item:" + dataItemUri);
                            }
                        }
                    });
        }
    } else {
        Log.e(TAG, "Failed to delete data items"
                 + " - Client disconnected from Google Play Services");
    }
}
 
開發者ID:googlesamples,項目名稱:android-AgendaData,代碼行數:27,代碼來源:MainActivity.java

示例11: ExtractedDataItem

import com.google.android.gms.wearable.DataItem; //導入方法依賴的package包/類
public ExtractedDataItem (DataItem d) {
    uri = d.getUri();
    path = uri.getPath();
    DataMap m = DataMapItem.fromDataItem(d).getDataMap();
    timestamp = m.getLong("timestamp");
    state = m.getBoolean("state");
    dataitem = d;
}
 
開發者ID:google,項目名稱:wear-displaylock,代碼行數:9,代碼來源:GetFirstDataItem.java

示例12: onDataChanged

import com.google.android.gms.wearable.DataItem; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.d("count=" + dataEvents.getCount());
    // There should always be only one item, but we iterate to be safe
    for (DataEvent dataEvent : dataEvents) {
        DataItem dataItem = dataEvent.getDataItem();
        Uri uri = dataItem.getUri();
        Log.d("uri=" + uri);
        String path = uri.getPath();
        Log.d("path=" + path); int type = dataEvent.getType(); Log.d("type=" + LogUtil.getConstantName(DataEvent.class, type, "TYPE_"));
        if (type == DataEvent.TYPE_DELETED) {
            dismissNotification();
        } else {
            DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
            DataMap dataMap = dataMapItem.getDataMap();
            String title = dataMap.getString(WearHelper.EXTRA_TITLE); String textShort = dataMap.getString(WearHelper.EXTRA_TEXT_SHORT);
            String textLong = dataMap.getString(WearHelper.EXTRA_TEXT_LONG);
            Asset photoAsset = dataMap.getAsset(WearHelper.EXTRA_PHOTO);
            Bitmap photo = null;
            if (photoAsset != null) {
                // Blocking
                mWearHelper.connect(this);
                photo = mWearHelper.loadBitmapFromAsset(photoAsset);
            }
            byte[] contactUriBytes = dataMap.getByteArray(WearHelper.EXTRA_CONTACT_URI);
            Uri contactUri = ParcelableUtil.unparcel(contactUriBytes, Uri.CREATOR);
            String phoneNumber = dataMap.getString(WearHelper.EXTRA_PHONE_NUMBER);

            showNotification(title, textShort, textLong, photo, contactUri, phoneNumber);
        }
    }
}
 
開發者ID:BoD,項目名稱:DoorCodeNotifier,代碼行數:33,代碼來源:NotificationWearableListenerService.java

示例13: onDataChanged

import com.google.android.gms.wearable.DataItem; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.d("count=" + dataEvents.getCount());
    // There should always be only one item, but we iterate to be safe
    for (DataEvent dataEvent : dataEvents) {
        DataItem dataItem = dataEvent.getDataItem();
        Uri uri = dataItem.getUri();
        Log.d("uri=" + uri);
        String path = uri.getPath();
        Log.d("path=" + path);
        if (dataEvent.getType() == DataEvent.TYPE_DELETED) {
            dismissNotification();
        }
    }
}
 
開發者ID:BoD,項目名稱:DoorCodeNotifier,代碼行數:16,代碼來源:NotificationWearableListenerService.java

示例14: resetDataItems

import com.google.android.gms.wearable.DataItem; //導入方法依賴的package包/類
private void resetDataItems(List<DataItem> dataItemList) {
    if (mGoogleApiClient.isConnected()) {
        for (final DataItem dataItem : dataItemList) {
            final Uri dataItemUri = dataItem.getUri();
            Wearable.DataApi.getDataItem(mGoogleApiClient, dataItemUri)
                    .setResultCallback(new ResetDataItemCallback());
        }
    } else {
        Log.e(TAG, "Failed to reset data items because client is disconnected from "
                + "Google Play Services");
    }
}
 
開發者ID:mauimauer,項目名稱:AndroidWearable-Samples,代碼行數:13,代碼來源:MainActivity.java

示例15: deleteDataItems

import com.google.android.gms.wearable.DataItem; //導入方法依賴的package包/類
private void deleteDataItems(DataItemBuffer dataItems) {
    if (mGoogleApiClient.isConnected()) {
        // Store the DataItem URIs in a List and close the buffer. Then use these URIs
        // to delete the DataItems.
        final List<DataItem> dataItemList = FreezableUtils.freezeIterable(dataItems);
        dataItems.close();
        for (final DataItem dataItem : dataItemList) {
            final Uri dataItemUri = dataItem.getUri();
            // In a real calendar application, this might delete the corresponding calendar
            // event from the calendar data provider. In this sample, we simply delete the
            // DataItem, but leave the phone's calendar data intact.
            Wearable.DataApi.deleteDataItems(mGoogleApiClient, dataItemUri)
                    .setResultCallback(new ResultCallback<DataApi.DeleteDataItemsResult>() {
                        @Override
                        public void onResult(DataApi.DeleteDataItemsResult deleteResult) {
                            if (deleteResult.getStatus().isSuccess()) {
                                appendLog("Successfully deleted data item: " + dataItemUri);
                            } else {
                                appendLog("Failed to delete data item:" + dataItemUri);
                            }
                        }
                    });
        }
    } else {
        Log.e(TAG, "Failed to delete data items"
                 + " - Client disconnected from Google Play Services");
    }
}
 
開發者ID:mauimauer,項目名稱:AndroidWearable-Samples,代碼行數:29,代碼來源:MainActivity.java


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