当前位置: 首页>>代码示例>>Java>>正文


Java PutDataMapRequest.createFromDataMapItem方法代码示例

本文整理汇总了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());
}
 
开发者ID:The-WebOps-Club,项目名称:saarang-iosched,代码行数:37,代码来源:HomeListenerService.java


注:本文中的com.google.android.gms.wearable.PutDataMapRequest.createFromDataMapItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。