當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。