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