本文整理匯總了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());
}