本文整理汇总了Java中android.preview.support.wearable.notifications.WearableNotifications类的典型用法代码示例。如果您正苦于以下问题:Java WearableNotifications类的具体用法?Java WearableNotifications怎么用?Java WearableNotifications使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WearableNotifications类属于android.preview.support.wearable.notifications包,在下文中一共展示了WearableNotifications类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showPhotoNotificaion
import android.preview.support.wearable.notifications.WearableNotifications; //导入依赖的package包/类
public void showPhotoNotificaion() {
mNotificationManager.cancel(2);
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(getContext())
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(getContext().getString(R.string.notification_title_photo))
.setContentText(getContext().getString(R.string.notification_content_photo))
.addAction(android.R.drawable.ic_menu_camera,
getContext().getString(R.string.gopro_action_take_photo),
getActionPendingIntent(GoProAction.TAKE_PHOTO))
.addAction(android.R.drawable.ic_menu_revert, getContext().getString(
R.string.notification_back),
getShowDefaultNotificationPendingIntent()
)
.setDeleteIntent(getActionDismissedPendingIntent());
Notification n1 = new WearableNotifications.Builder(notificationBuilder)
.setGroup(GROUP_ID, 1)
.build();
mNotificationManager.notify(1, n1);
}
示例2: sendNotification
import android.preview.support.wearable.notifications.WearableNotifications; //导入依赖的package包/类
private void sendNotification(int color) {
final int notificationId = 1;
int resourceid = R.drawable.ic_marker;
if(color==Color.MAGENTA) {
resourceid = R.drawable.ic_marker2;
} else if(color==Color.BLUE) {
resourceid = R.drawable.ic_marker3;
}
final Bitmap bitmapIcon = BitmapFactory.decodeResource(this.getResources(), resourceid);
NotificationManagerCompat.from(this).cancelAll();
Intent viewIntent = new Intent(this, RangingDemoActivity.class);
viewIntent.putExtra(EXTRA_EVENT_ID, notificationId);
PendingIntent viewPendingIntent = PendingIntent.getActivity(this, 0, viewIntent, 0);
String eventTitle = getString(R.string.app_name);
String eventLocation = "- beacon in the area -";
if(color==Color.RED) {
eventLocation = "Beacon Found!";
} else if(color==Color.MAGENTA) {
eventLocation = "getting closer...";
}
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setContentTitle(eventTitle)
.setContentText(eventLocation)
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(bitmapIcon)
.setContentIntent(viewPendingIntent);
Notification notification = new WearableNotifications.Builder(notificationBuilder).build();
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
notificationManager.notify(notificationId, notification);
}
示例3: showVideoNotificaion
import android.preview.support.wearable.notifications.WearableNotifications; //导入依赖的package包/类
public void showVideoNotificaion() {
mNotificationManager.cancel(2);
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(getContext())
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(getContext().getString(R.string.notification_title_video))
.setContentText(getContext().getString(
R.string.notification_title_content_video))
.addAction(android.R.drawable.ic_media_play,
getContext().getString(R.string.gopro_action_start_video),
getActionPendingIntent(GoProAction.START_VIDEO))
.addAction(android.R.drawable.ic_media_pause, getContext().getString(
R.string.gopro_action_stop_video),
getActionPendingIntent(GoProAction.STOP_VIDEO)
)
.addAction(android.R.drawable.ic_menu_revert, getContext().getString(
R.string.notification_back),
getShowDefaultNotificationPendingIntent()
)
.setDeleteIntent(getActionDismissedPendingIntent());
Notification n1 = new WearableNotifications.Builder(notificationBuilder)
.setGroup(GROUP_ID, 1)
.build();
mNotificationManager.notify(1, n1);
}
示例4: showStartNotification
import android.preview.support.wearable.notifications.WearableNotifications; //导入依赖的package包/类
public void showStartNotification() {
// visible on the phone
NotificationCompat.Builder summaryBuilder =
new NotificationCompat.Builder(getContext())
.setSmallIcon(R.drawable.ic_launcher)
.setAutoCancel(true)
.setContentTitle(
getContext().getString(
R.string.notification_title_gopro_device)
).setContentText(
getContext().getString(R.string.notification_content_gopro_device));
Notification summary = new WearableNotifications.Builder(summaryBuilder)
.setGroup(GROUP_ID, WearableNotifications.GROUP_ORDER_SUMMARY)
.build();
mNotificationManager.notify(0, summary);
// first notification on wear
NotificationCompat.Builder modeNotificationBuilder =
new NotificationCompat.Builder(getContext())
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(getContext().getString(
R.string.notification_title_gopro_wear_remote))
.setContentText(
getContext().getString(
R.string.notification_content_gopro_wear)
)
.addAction(android.R.drawable.ic_menu_camera,
getContext().getString(R.string.gopro_action_mode_photo),
getSwitchModePendingIntent(GoProAction.SWITCH_TO_PHOTO))
.addAction(android.R.drawable.ic_menu_slideshow,
getContext().getString(R.string.gopro_action_mode_video),
getSwitchModePendingIntent(GoProAction.SWITCH_TO_VIDEO));
Notification mode = new WearableNotifications.Builder(modeNotificationBuilder)
.setGroup(GROUP_ID, 1)
.build();
mNotificationManager.notify(1, mode);
NotificationCompat.Builder moreNotificationBuilder =
new NotificationCompat.Builder(getContext())
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(getContext().getString(R.string.notification_title_more))
.setContentText(getContext().getString(R.string.notification_content_more))
.addAction(android.R.drawable.ic_lock_power_off,
getContext().getString(R.string.gopro_action_on),
getActionPendingIntent(GoProAction.POWER_ON))
.addAction(android.R.drawable.ic_media_pause, getContext().getString(
R.string.gopro_action_off),
getActionPendingIntent(GoProAction.POWER_OFF)
)
.setDeleteIntent(getActionDismissedPendingIntent());
Notification n1 = new WearableNotifications.Builder(moreNotificationBuilder)
.setGroup(GROUP_ID, 2)
.build();
mNotificationManager.notify(2, n1);
}