PutDataRequest

  • PutDataRequest is used to create new data items in the Android Wear network.

  • The class includes constants like WEAR_URI_SCHEME and methods to create, get, add, remove, and set data or assets on a data item.

  • It also provides methods to manage the urgency of data item transport and is Parcelable for efficient data transfer.

public classPutDataRequest extendsObject
implementsParcelable

PutDataRequest is used to create new data items in the Android Wear network.

Constant Summary

String WEAR_URI_SCHEMEURI scheme to use for Wear URIs.

Inherited Constant Summary

From interface android.os.Parcelable
intCONTENTS_FILE_DESCRIPTOR
intPARCELABLE_WRITE_RETURN_VALUE

Field Summary

public static finalCreator<PutDataRequest>CREATOR

Public Method Summary

staticPutDataRequest
create(String path)
Creates aPutDataRequest with the provided, complete, path.
staticPutDataRequest
createFromDataItem(DataItem source)
Creates aPutDataRequest from an existingDataItem using the provided source.
staticPutDataRequest
createWithAutoAppendedId(String pathPrefix)
Creates aPutDataRequest with a randomly generated id prefixed with the provided path.
Asset
getAsset(String key)
Returns anAsset previously added with putAsset(String, Asset).
Map<StringAsset>
getAssets()
Returns unmodifiable map ofAssets on thisDataItem.
byte[]
getData()
An array of data stored at the specifiedUri.
Uri
getUri()
Returns aUri for the pending data item.
boolean
hasAsset(String key)
Returnstrue if the asset exists in this data item.
boolean
isUrgent()
Whether theDataItem for this request is urgent.
PutDataRequest
putAsset(String key,Asset value)
Adds anAsset to the data item.
PutDataRequest
removeAsset(String key)
Removes a previously addedAsset.
PutDataRequest
setData(byte[] data)
Sets the data in a data item.
PutDataRequest
setUrgent()
Flags thisDataItem for urgent transport.
String
String
toString(boolean verbose)
void
writeToParcel(Parcel dest, int flags)

Inherited Method Summary

From class java.lang.Object
Object
clone()
boolean
equals(Object arg0)
void
finalize()
finalClass<?>
getClass()
int
hashCode()
final void
notify()
final void
notifyAll()
String
toString()
final void
wait(long arg0, int arg1)
final void
wait(long arg0)
final void
wait()
From interface android.os.Parcelable
abstract int
describeContents()
abstract void
writeToParcel(Parcel arg0, int arg1)

Constants

public static finalStringWEAR_URI_SCHEME

URI scheme to use for Wear URIs. SeeDataApi for details of the Wear URI format.

Constant Value:"wear"

Fields

public static finalCreator<PutDataRequest>CREATOR

Public Methods

public staticPutDataRequestcreate(String path)

Creates aPutDataRequest with the provided, complete, path.

public staticPutDataRequestcreateFromDataItem(DataItem source)

Creates aPutDataRequest from an existingDataItem using the provided source.

public staticPutDataRequestcreateWithAutoAppendedId(String pathPrefix)

Creates aPutDataRequest with a randomly generated id prefixed with the provided path.

publicAssetgetAsset(String key)

Returns anAsset previously added with putAsset(String, Asset).

publicMap<StringAsset>getAssets()

Returns unmodifiable map ofAssets on thisDataItem.

public byte[]getData()

An array of data stored at the specifiedUri.PutDataMapRequest may be used to store structured data in the network.

publicUrigetUri()

Returns aUri for the pending data item. If this is a modification of an existing data item,Uri.getHost() will return the id of the node that originally created it. Otherwise, a new data item will be created with the requesting device's node.

public booleanhasAsset(String key)

Returnstrue if the asset exists in this data item.

public booleanisUrgent()

Whether theDataItem for this request is urgent.

Returns
  • true if theDataItem for this request is urgent

publicPutDataRequestputAsset(String key,Asset value)

Adds anAsset to the data item.

publicPutDataRequestremoveAsset(String key)

Removes a previously addedAsset.

publicPutDataRequestsetData(byte[] data)

Sets the data in a data item.

Note: Use an empty array if there is no data to store.null is only allowed for backwards compatibility.

publicPutDataRequestsetUrgent()

Flags thisDataItem for urgent transport. Updates toDataItems with the same path will be applied in the order they are received. A subsequent urgent update will remove the delay for pending updates. A subsequent delayed update will not delay pending urgent updates.

Non-urgentDataItems will be delayed no longer than 30 minutes, subject to a connected peer, but are expected to arrive much sooner.

Clients should onlysetUrgent() forDataItems which need to be delivered right away.

publicStringtoString()

publicStringtoString(boolean verbose)

public voidwriteToParcel(Parcel dest, int flags)

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-11-21 UTC.