本文整理汇总了Java中com.google.android.gms.wearable.PutDataMapRequest.createFromDataMapItem方法的典型用法代码示例。如果您正苦于以下问题:Java PutDataMapRequest.createFromDataMapItem方法的具体用法?Java PutDataMapRequest.createFromDataMapItem怎么用?Java PutDataMapRequest.createFromDataMapItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.wearable.PutDataMapRequest
的用法示例。
在下文中一共展示了PutDataMapRequest.createFromDataMapItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupNotification
import com.google.android.gms.wearable.PutDataMapRequest; //导入方法依赖的package包/类
/**
* Builds notification for wear based on the data in the Data Item that is passed in.
*/
private void setupNotification(DataItem dataItem) {
LOGD(TAG, "setupNotification(): DataItem=" + dataItem.getUri());
PutDataMapRequest putDataMapRequest = PutDataMapRequest
.createFromDataMapItem(DataMapItem.fromDataItem(dataItem));
final DataMap dataMap = putDataMapRequest.getDataMap();
String sessionId = dataMap.getString(KEY_SESSION_ID);
String sessionRoom = dataMap.getString(KEY_SESSION_ROOM);
String sessionName = dataMap.getString(KEY_SESSION_NAME);
String speakers = dataMap.getString(KEY_SPEAKER_NAME);
int notificationId = (int) new Date().getTime();
Intent intent = new Intent(ACTION_DISMISS);
intent.putExtra(KEY_SESSION_ID, dataMap.getString(KEY_SESSION_ID));
// need to be notified if user dismisses teh notification so we can dismiss the
// corresponding notification on teh paired handset.
PendingIntent deleteIntent = PendingIntent
.getService(this, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent showCardIntent = showCardIntent(sessionId, sessionRoom, sessionName,
speakers, notificationId);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(getString(R.string.rate_this_session))
.setDeleteIntent(deleteIntent)
.setContentText(sessionName)
.extend(new NotificationCompat.WearableExtender()
.setDisplayIntent(showCardIntent));
NotificationManagerCompat.from(this)
.notify(sessionId, NOTIFICATION_ID, builder.build());
}