本文整理汇总了Java中com.google.android.gms.wearable.PutDataMapRequest.createWithAutoAppendedId方法的典型用法代码示例。如果您正苦于以下问题:Java PutDataMapRequest.createWithAutoAppendedId方法的具体用法?Java PutDataMapRequest.createWithAutoAppendedId怎么用?Java PutDataMapRequest.createWithAutoAppendedId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.wearable.PutDataMapRequest
的用法示例。
在下文中一共展示了PutDataMapRequest.createWithAutoAppendedId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: syncTicketsToWear
import com.google.android.gms.wearable.PutDataMapRequest; //导入方法依赖的package包/类
private void syncTicketsToWear(String path) {
Uri uri = Uri.parse(path);
final ArrayList<DataMap> dataCities = new ArrayList<DataMap>();
String cityName = uri.getLastPathSegment();
List<City> cities = CityManager.get(getApplicationContext()).getTicketsInCity(cityName, getApplicationContext());
for (final City city : cities) {
final DataMap dataMap = new DataMap();
dataMap.putLong("id", city.id);
dataMap.putString("city", city.city);
dataMap.putString("country", city.country);
dataMap.putInt("validity", city.validity);
dataMap.putString("price", city.price);
dataMap.putString("currency", city.currency);
dataMap.putString("price_note", city.priceNote);
dataMap.putString("note", city.note);
dataCities.add(dataMap);
}
PutDataMapRequest data = PutDataMapRequest.createWithAutoAppendedId("/tickets");
data.getDataMap().putDataMapArrayList("tickets", dataCities);
syncDataItem(data);
}
示例2: sendSmsNotification
import com.google.android.gms.wearable.PutDataMapRequest; //导入方法依赖的package包/类
private void sendSmsNotification(Ticket t, int status) {
DebugLog.d("Send ticket to wear" + t.toString());
final DataMap dataMap = new DataMap();
dataMap.putLong("id", t.getId());
dataMap.putLong("city_id", t.getCityId());
dataMap.putString("city", t.getCity());
dataMap.putInt("status", status);
dataMap.putString("hash", t.getHash());
dataMap.putString("text", t.getText());
dataMap.putLong("valid_from", t.getValidFrom().toMillis(true));
dataMap.putLong("valid_to", t.getValidTo().toMillis(true));
dataMap.putLong("notification_id", t.getNotificationId());
PutDataMapRequest data = PutDataMapRequest.createWithAutoAppendedId("/notification");
data.getDataMap().putDataMap("notification", dataMap);
syncDataItem(data);
}
示例3: onSave
import com.google.android.gms.wearable.PutDataMapRequest; //导入方法依赖的package包/类
@Override
public void onSave(long tweetId, String[] urls, final Handler.Callback callback) {
PutDataMapRequest dataMap = PutDataMapRequest.createWithAutoAppendedId(Constants.PATH_POCKET_SAVE);
dataMap.getDataMap().putStringArray("urls", urls);
dataMap.getDataMap().putLong("id", tweetId);
PutDataRequest request = dataMap.asPutDataRequest();
PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi
.putDataItem(mGoogleApiClient, request);
pendingResult.setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
@Override
public void onResult(DataApi.DataItemResult dataItemResult) {
Log.i(TAG, "data send status:" + dataItemResult.getStatus());
callback.handleMessage(null);
}
});
}
示例4: sendError
import com.google.android.gms.wearable.PutDataMapRequest; //导入方法依赖的package包/类
/**
* Sends error to wearable.
*/
private void sendError(String message) {
DebugLog.e(message);
PutDataMapRequest data = PutDataMapRequest.createWithAutoAppendedId("/error");
data.getDataMap().putString("error_message", message);
syncDataItem(data);
}
示例5: syncCitiesToWear
import com.google.android.gms.wearable.PutDataMapRequest; //导入方法依赖的package包/类
private void syncCitiesToWear() {
CityManager cityManager = CityManager.get(getApplicationContext());
List<City> cities = cityManager.getUniqueCities(getApplication());
if (cities.size() > 0) {
ArrayList<City> orderedCities = new ArrayList<>();
LocationManager lm = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
Location location = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (location != null) {
City closest = cityManager.getClosest(this, location.getLatitude(), location.getLongitude());
if (closest != null) {
orderedCities.add(closest);
for (int i = 0; i < cities.size(); i++) {
if (closest.id != cities.get(i).id) {
orderedCities.add(cities.get(i));
}
}
} else {
orderedCities.addAll(cities);
}
}
final ArrayList<DataMap> dataCities = new ArrayList<DataMap>();
for (final City city : orderedCities) {
final DataMap dataMap = new DataMap();
dataMap.putLong("id", city.id);
dataMap.putString("city", city.city);
dataMap.putString("country", city.country);
dataCities.add(dataMap);
}
if (dataCities.size() == 0) {
UpdateService.call(getApplicationContext(), false);
sendError(getResources().getString(R.string.error_zero_cities));
} else {
PutDataMapRequest data = PutDataMapRequest.createWithAutoAppendedId("/cities");
data.getDataMap().putDataMapArrayList("cities", dataCities);
syncDataItem(data);
}
} else {
UpdateService.call(getApplicationContext(), false);
sendError(getResources().getString(R.string.error_zero_cities));
}
}